Take bash startup file(s) with you into ssh?

Viewed 305

Is it possible to "bring with you" a copy of bash_profile from the source machine when doing an ssh to remote? And maybe even automatically source it right after login? If so, how can I do this? I can probably imagine some really elaborate shell hack (unless this is somehow restricted due to security concerns), but maybe there's a nice and clean way.

1 Answers

In my ~/.ssh/config I have an entry to choose the remote session file to use when log on in a server. In my case I use a specific rc file instead of .bashrc.

Host *
LocalCommand scp ~/.remote_bashrc %r@%n:/home/%r
RemoteCommand bash --rcfile "~/.remote_bashrc"

First, one copies the file to the remote.

Second, one uses it as shell session configuration.

Related