OpenSSH lets you use per-host settings in your ~/.ssh/config file, like so:

Host foo
ForwardX11 no

If you have the above in your ~/.ssh/config file, you can simply type ssh foo instead of ssh -x

It’s pretty much always the case that I’ll fire up GNU Screen when SSHing into a remote host. Here’s some code that’s been banging around in my .cshrc for a few years. It sets up handy shell aliases for all of the machines I commonly SSH into:

set ssh_hosts=`grep '^Host [^*]' ~/.ssh/config|cut -c 6-`

foreach host ($ssh_hosts)
    alias $host "ssh -t $host screen -DR"

Now I can simply type foo and I’ll be up and running with a screen session on If I want to SSH into a box without firing screen up, I simpy ssh foo directly.

Now that we have this handy ssh_hosts variable, we might as well use it for other things too, like for adding intelligent tab completion:

complete ssh 'p/1/$ssh_hosts/'

Now I can just type ssh f TAB RET and I’m good to go.

Add a comment