SSHrc along with your local configuration

Russell91 has developed a ssh script that besides the usual ssh, it also sources the ~/.sshrc on your local computer after logging in remotely.

You can use this to set environment variables, define functions, and run post-login commands. It’s that simple, and it won’t impact other users on the server – even if they use sshrc too. This makes sshrc very useful if you share a server with multiple users and can’t edit the server’s ~/.bashrc without affecting them, or if you have several servers that you don’t want to configure independently.

Advanced configuration

Your most import configuration files (e.g. vim, inputrc) may not be bash scripts. Put them in ~/.sshrc.d and sshrc will copy them to a (guaranteed) unique folder in the server’s /tmp directory after login. You can find them at $SSHHOME/.sshrc.d

You can usually tell programs to load their configuration from the $SSHHOME/.sshrc.d directory by setting the right environment variables. For example, vim uses the VIM environment variable.

Vim Integration

Vim might not work by default when executing sshrc, mostly due to the following reasons:

1. You have plugins that are not automatically sent

You can symlink everything from your vim home into the .sshrc.d folder. This way, the plugins will surely be available

If syntax.vim cannot be loaded, symlink that one too:

 (yours may not be found in that location. Make sure to search it first)

2. Your .vimrc is not automatically loaded when firing up vim on the remote host

I’ve managed to fix this by making sure to have the following lines in my ~/.sshrc file

3. Your configuration may include settings that are not available for the targeted operating system

This one is pretty simple to fix. Check the Cross-Platform section and embed the required config within it.

Final thoughts on .sshrc

I think .sshrc is fantastic, and it’s a shame that it was developed 10 years later than it should’ve been. But hey, it’s here, so no other comments. I really like that the files are sent using xxd so there’s just one-way trip and the code is pretty easy to understand and to change.

Many people are going to get enthusiastic again and start configuring their vim, bash just because they now have a way to transport those configurations to any server. Honestly, doing personalising your experience on the local machine is great, and it’s giving you a small boost just because of the comfort zone it creates around it. But when you ssh on another server and there are no more custom shortcuts, no colours, nothing it’s just a bummer. And as ssh-ing goes by, your forget to maintain it, to improve it just because on another server everything will be pretty useless. True story.

So cheers Russel91, great job man!