Creating SSH Shortcuts Using SSH Config
From Brain Mapping
SSH Config is a great place to make shortcuts for those long url's your always typing. In just a few seconds you'll never have to type: fmri00-silly.ats.long.hosted.domain.name.that.goes.on.forever.com. We'll take the example of ssh'ing into miles, then into one of the other compute nodes to demonstrate the most awesome power of ssh config.
The ssh config file resides in $HOME/.ssh/config. If it doesn't exist, just create it.
$ vim ~/.ssh/config
Of course, you can use any text editor you want except for TextEdit. Because TextEdit is evil. Trust me. Next, we just need to make a few entries:
# Enter the short name you'd like to use. This is an arbitrary name and can be anything you'd like
- Here we use miles, but it could be hoffman, work, home, func, or whatever else you'd like
Host miles # Next, enter the full url to the server you want to log into for the last time! Here we use miles, but it can be any server you'd like to access # such as hoffman2.idre.ucla.edu for hoffman Hostname fmri00-miles.hosted.ats.ucla.edu # Then enter the user name needed to log into this host. foo is just an example, your username is specific to your account User foo # Finally, set x11 forwarding to yes if you want gui awesomeness ForwardX11 yes
That's it! This should be put in the $HOME/.ssh/config that your logging in from. So for miles, you'd put this on your laptop, office, or home computer. If you'd also like to use short cuts on miles itself then you can enter this in your ssh config on miles.
Host cannonball Hostname fmri02-cannonball User foo ForwardX11 yes
Of course, replace the cannonball url with whichever computer node you use and replace foo with your username. Unless, of course, you happen to be foo. Then you have my sincerest apologies for the blatant abuse of your name.
Don't stop reading! There's one last thing to do. After editing the file you have to make sure the permissions are right or ssh will refuse to use it. So type this when your done editing:
$ chmod 600 ~/.ssh/config
After this is done, all that's needed to ssh into miles from the terminal is:
$ ssh miles
You can even copy/paste it if you like. For a full list of all the magical options available in .ssh/config you can check out the /etc/ssh_config or
$ man ssh_config

