The ssh client has a config file?


#1

A long time a go a coworker documented the ssh forwarding with xinetd trick that i showed him. We use it heavily on our virtualisation cluster for openSUSE. Of course it gets annoying if you have to pass the port parameter to each invocation of ssh or scp. Especially since ssh and scp are so nicely consistent for that. :wink:

As the title already implies, ssh has a config file which we can use. It allows us to basically set every setting that can also pass via command line argument and all that per host.

Host myopensusevm.opensuse.org
   Port 2201
   User root

Neat right? 2 arguments we don’t have to pass to ssh or scp anymore. Another nice side effect scp root@myopensusevm.opensuse.org:/tmp/foo<tab><tab> actually works now and does not time out anymore as scp -P 2201 root@myopensusevm.opensuse.org:/tmp/foo<tab><tab> did.

Though it is still annoying that you always have to type this very long hostname. Luckily the config can help us here too:

Host myvm
   Port 2201
   User root
   Hostname myopensusevm.opensuse.org

ssh myvm will just work. no matter where you are right now.

Hope this helps a little :slight_smile:

P.S.: for more see man ssh or man ssh_config