I need to login into several remote ssh servers during my admin work. I work with three different computers client side, all of them are Debian GNU/Linux systems. I keep a workspace directory where I put everything I need to do my job, and that directory contains, among other things, a bashrc
file and a ssh_config
file.
I manually sync that directory contents with a script that uses rsync
from one client computer to the others as I move and start using a different client.
The local user on each of the three clients needs minimal configuration, so that if I need to create a new local user or reinstall a client, I have only to rsync
the workspace and to add a reference to my custom workspace/bashrc
in the real user's $HOME/.bashrc
. My custom workspace/bashrc
creates several aliases and I get my usual environment regardless of the client I'm using.
My custom workspace/bashrc
creates aliases to connect to remote servers this way:
alias s1='ssh -F ~/workspace/etc/ssh_config server1.example.com'
and I log into server1 by just typing s1
in a terminal of any client, because my custom ssh_config
sets the needed public key authentication options, the correct port server1 is listening on and the correct user.
Now this works like a charm, as long as the ssh
command is what I need. Unfortunately, as soon as I need another command that in turn uses ssh
, things become more chaotic.
E.g. if I need to rsync
anything to one of those servers, I'm forced to write the whole ssh command:
rsync -Pavz --delete -e "ssh -F $HOME/workspace/etc/ssh_config" ...
Similar things happen with other commands such as scp
, ssh-copy-id
and others.
I'd like to be able to write
rsync -Pavz --delete -e "ssh" ...
instead, and have ssh take it's configuration file name from a environment variable, so that I can set that environment variable in my bashrc
and every ssh
invocation automagically works.
Is there such environment variable or is there a different solution to the problem?