Using SSHpass and Bash Alias’ to speed up SSH access

Speeding up SSH access

Posted on September 16, 2014

Here’s a handy little utility for automatically sending your SSH password when connecting to your server via SSH with a Bash Alias shortcut.

Rather than having to type

ssh root@1.1.1.1
/*where 1.1.1.1 is the servers IP*/

and then manually entering my password, which if you’re anything like me you’ll have to search for. You can simply set up a list of shortcuts in your .bash_profile file to speed up access.

For example, I’ve have four SSH shortcuts setup for different servers which allow me to SSH into them by simply typing

sshmyservername

The first thing you need to do is install the sshpass utility:

brew install https://raw.github.com/eugeneoden/homebrew/eca9de1/Library/Formula/sshpass.rb

Now it’s just case of adding your shortcuts to your .bash_profile file. Edit your bash_profile file with your favourite editor (I use nano):

nano ~/.bash_profile

and add a shortcut:

alias myshortcutname='sshpass -p 'PASSWORD' ssh root@SERVER_IP'

You can then quickly SSH into your server by typing myshortcutname in terminal.