3

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?

1 Answer 1

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
4
  • 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, 2019 at 11:05
  • even so, this still stops me from keeping my own shell and theme... ?
    – Skipper
    Jan 23, 2019 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, 2019 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, 2019 at 12:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .