How to create an alias for SSH

I have found myself in typing out that long ssh command string every time when I need to connect our VPS server is not only boring but also time consuming. If you’re like me, you should also be tired of typing long ssh command strings in your day-to-day work. So, wouldn’t it be nice to have a shorter ssh string to save that extra key strokes?

Let us create an alias for the ssh command to make it shorter.

Fire up your terminal, then execute the following command to create an alias file in your home.

sudo nano ~/.bash_aliases

After creating the file, write our alias command for ssh into it. Make sure to choose an easy to remember name for the alias.

alias sshserver='ssh root@'

save and close the file

source ~/.bashrc

Now, instead of executing ssh root@ to make an SSH connection, you can use the alias command sshserver

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>