SSH Tips

I cannot remember where I got the first of these tips from, but I really am grateful for learning of it. I spend a fair amount of time ssh-ing into various machine I use. Having to type out the full command ’ssh [machine name]‘ is quite annoying - especially as some of the full machine names we use are long. I use Kubuntu, with bash for the shell - this tip may need editing for other shells.
Add a line to /etc/hosts ‘[ip address] [machine alias]‘ - i.e.
192.168.2.67 server
Then add to .bashrc ‘alias [alias]=”ssh [machine alias]“‘ - i.e.
alias server="ssh server"
Then you type just server to ssh into the machine and can also use ’server’ as the machine name for other commands, such as in scp.

Also, we have several servers running ssh on a non-standard port. Just a small addition to the file ‘~/.ssh/config’ (this file may need to be created) can solve this problem.
host server
hostname 192.168.2.67
port 456

Leave a Reply