Keep local shell for remote ssh sessions












0















I've recently started customising my shell on my mac (mojave). I now run a fairly customised zsh shell with oh-my-zsh and a number of other plugins/themes/customisations.



Enter remote servers (rhel). How do I keep using my own shell, with my own customisations (aliases, functions, theme, etc) on my remote ssh session.



Basically, I want to "pull" the remote ssh session onto my local machine, while sticking to using my own setup. I've already copied my aliases and functions to the remote session as part of an ssh function, but if I sudo into another user on the remote server, I again lose the aliases/functions. So, while that works for now, I want to see the next level of this.



Any ideas?










share|improve this question



























    0















    I've recently started customising my shell on my mac (mojave). I now run a fairly customised zsh shell with oh-my-zsh and a number of other plugins/themes/customisations.



    Enter remote servers (rhel). How do I keep using my own shell, with my own customisations (aliases, functions, theme, etc) on my remote ssh session.



    Basically, I want to "pull" the remote ssh session onto my local machine, while sticking to using my own setup. I've already copied my aliases and functions to the remote session as part of an ssh function, but if I sudo into another user on the remote server, I again lose the aliases/functions. So, while that works for now, I want to see the next level of this.



    Any ideas?










    share|improve this question

























      0












      0








      0








      I've recently started customising my shell on my mac (mojave). I now run a fairly customised zsh shell with oh-my-zsh and a number of other plugins/themes/customisations.



      Enter remote servers (rhel). How do I keep using my own shell, with my own customisations (aliases, functions, theme, etc) on my remote ssh session.



      Basically, I want to "pull" the remote ssh session onto my local machine, while sticking to using my own setup. I've already copied my aliases and functions to the remote session as part of an ssh function, but if I sudo into another user on the remote server, I again lose the aliases/functions. So, while that works for now, I want to see the next level of this.



      Any ideas?










      share|improve this question














      I've recently started customising my shell on my mac (mojave). I now run a fairly customised zsh shell with oh-my-zsh and a number of other plugins/themes/customisations.



      Enter remote servers (rhel). How do I keep using my own shell, with my own customisations (aliases, functions, theme, etc) on my remote ssh session.



      Basically, I want to "pull" the remote ssh session onto my local machine, while sticking to using my own setup. I've already copied my aliases and functions to the remote session as part of an ssh function, but if I sudo into another user on the remote server, I again lose the aliases/functions. So, while that works for now, I want to see the next level of this.



      Any ideas?







      linux ssh zsh






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 23 at 10:14









      SkipperSkipper

      1




      1






















          1 Answer
          1






          active

          oldest

          votes


















          0














          If you use su to switch ids, you keep your current environment (use su - to have a fresh environment for the user you switch to). So the simpler way would be:





          • sudo/su to root

          • have a shell profile (called manually is there are other admin users on the server)

          • use su to switch to other users






          share|improve this answer
























          • so are you saying I should say sudo -s to sudo into root and then sudo <user> to sudo into the user I need? If I do sudo -s I lose the session, but if I do sudo s or sudo root it doesn't work at all?

            – Skipper
            Jan 23 at 11:05











          • even so, this still stops me from keeping my own shell and theme... ?

            – Skipper
            Jan 23 at 11:07











          • No you 1) do sudo (or log in as root), then 2) set up the environment (automatic with profile or "manual" with script) and 3) use su to switch to another user, keeping your environment.

            – xenoid
            Jan 23 at 13:14











          • Thanks for the advice. This will definitely help. But I'd still like to know how to keep my own shell while ssh'ing into a remote machine.

            – Skipper
            Jan 24 at 12:54











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1397389%2fkeep-local-shell-for-remote-ssh-sessions%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          If you use su to switch ids, you keep your current environment (use su - to have a fresh environment for the user you switch to). So the simpler way would be:





          • sudo/su to root

          • have a shell profile (called manually is there are other admin users on the server)

          • use su to switch to other users






          share|improve this answer
























          • so are you saying I should say sudo -s to sudo into root and then sudo <user> to sudo into the user I need? If I do sudo -s I lose the session, but if I do sudo s or sudo root it doesn't work at all?

            – Skipper
            Jan 23 at 11:05











          • even so, this still stops me from keeping my own shell and theme... ?

            – Skipper
            Jan 23 at 11:07











          • No you 1) do sudo (or log in as root), then 2) set up the environment (automatic with profile or "manual" with script) and 3) use su to switch to another user, keeping your environment.

            – xenoid
            Jan 23 at 13:14











          • Thanks for the advice. This will definitely help. But I'd still like to know how to keep my own shell while ssh'ing into a remote machine.

            – Skipper
            Jan 24 at 12:54
















          0














          If you use su to switch ids, you keep your current environment (use su - to have a fresh environment for the user you switch to). So the simpler way would be:





          • sudo/su to root

          • have a shell profile (called manually is there are other admin users on the server)

          • use su to switch to other users






          share|improve this answer
























          • so are you saying I should say sudo -s to sudo into root and then sudo <user> to sudo into the user I need? If I do sudo -s I lose the session, but if I do sudo s or sudo root it doesn't work at all?

            – Skipper
            Jan 23 at 11:05











          • even so, this still stops me from keeping my own shell and theme... ?

            – Skipper
            Jan 23 at 11:07











          • No you 1) do sudo (or log in as root), then 2) set up the environment (automatic with profile or "manual" with script) and 3) use su to switch to another user, keeping your environment.

            – xenoid
            Jan 23 at 13:14











          • Thanks for the advice. This will definitely help. But I'd still like to know how to keep my own shell while ssh'ing into a remote machine.

            – Skipper
            Jan 24 at 12:54














          0












          0








          0







          If you use su to switch ids, you keep your current environment (use su - to have a fresh environment for the user you switch to). So the simpler way would be:





          • sudo/su to root

          • have a shell profile (called manually is there are other admin users on the server)

          • use su to switch to other users






          share|improve this answer













          If you use su to switch ids, you keep your current environment (use su - to have a fresh environment for the user you switch to). So the simpler way would be:





          • sudo/su to root

          • have a shell profile (called manually is there are other admin users on the server)

          • use su to switch to other users







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 23 at 10:26









          xenoidxenoid

          3,6803719




          3,6803719













          • so are you saying I should say sudo -s to sudo into root and then sudo <user> to sudo into the user I need? If I do sudo -s I lose the session, but if I do sudo s or sudo root it doesn't work at all?

            – Skipper
            Jan 23 at 11:05











          • even so, this still stops me from keeping my own shell and theme... ?

            – Skipper
            Jan 23 at 11:07











          • No you 1) do sudo (or log in as root), then 2) set up the environment (automatic with profile or "manual" with script) and 3) use su to switch to another user, keeping your environment.

            – xenoid
            Jan 23 at 13:14











          • Thanks for the advice. This will definitely help. But I'd still like to know how to keep my own shell while ssh'ing into a remote machine.

            – Skipper
            Jan 24 at 12:54



















          • so are you saying I should say sudo -s to sudo into root and then sudo <user> to sudo into the user I need? If I do sudo -s I lose the session, but if I do sudo s or sudo root it doesn't work at all?

            – Skipper
            Jan 23 at 11:05











          • even so, this still stops me from keeping my own shell and theme... ?

            – Skipper
            Jan 23 at 11:07











          • No you 1) do sudo (or log in as root), then 2) set up the environment (automatic with profile or "manual" with script) and 3) use su to switch to another user, keeping your environment.

            – xenoid
            Jan 23 at 13:14











          • Thanks for the advice. This will definitely help. But I'd still like to know how to keep my own shell while ssh'ing into a remote machine.

            – Skipper
            Jan 24 at 12:54

















          so are you saying I should say sudo -s to sudo into root and then sudo <user> to sudo into the user I need? If I do sudo -s I lose the session, but if I do sudo s or sudo root it doesn't work at all?

          – Skipper
          Jan 23 at 11:05





          so are you saying I should say sudo -s to sudo into root and then sudo <user> to sudo into the user I need? If I do sudo -s I lose the session, but if I do sudo s or sudo root it doesn't work at all?

          – Skipper
          Jan 23 at 11:05













          even so, this still stops me from keeping my own shell and theme... ?

          – Skipper
          Jan 23 at 11:07





          even so, this still stops me from keeping my own shell and theme... ?

          – Skipper
          Jan 23 at 11:07













          No you 1) do sudo (or log in as root), then 2) set up the environment (automatic with profile or "manual" with script) and 3) use su to switch to another user, keeping your environment.

          – xenoid
          Jan 23 at 13:14





          No you 1) do sudo (or log in as root), then 2) set up the environment (automatic with profile or "manual" with script) and 3) use su to switch to another user, keeping your environment.

          – xenoid
          Jan 23 at 13:14













          Thanks for the advice. This will definitely help. But I'd still like to know how to keep my own shell while ssh'ing into a remote machine.

          – Skipper
          Jan 24 at 12:54





          Thanks for the advice. This will definitely help. But I'd still like to know how to keep my own shell while ssh'ing into a remote machine.

          – Skipper
          Jan 24 at 12:54


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1397389%2fkeep-local-shell-for-remote-ssh-sessions%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

          is 'sed' thread safe

          How to make a Squid Proxy server?