/ Open Source Software

How to: SSH Aliases using SSHez

If you are reading this article, probably you have SSH'd into loads of servers and you would like an easy way to do so.

SSHez provides an easy way to set server aliases. SSH itself provides this function through the SSH config file located in ~/.ssh/config but there is no way to add your aliases except edit the file yourself.

For example:
Host rest_api
   HostName rest.example.com
   User oss
   Port 1026

Host db_server
   User oss

Host ng_client
  HostName angular.example.com
  User oss

This way you can access any of the above servers using ssh hostname (ex: ssh rest_api instead of ssh oss@rest.example.com -p 559)


It is a ruby gem that interfaces your config file. All you have to do is:

  • gem install sshez in your global gemset

  • Add a server alias sshez <alias> oss@rest.example.com -p 1026

  • Connect to your server any ssh <alias>

  • List your aliases sshez list

  • Remove an alias sshez remove <alias>

It is that easy!

The gem is currently in version 0.3.0, I will update the post whenever it is updated!

Mohamed Osama

Mohamed Osama

Software Engineer; Entrepreneur; Data analyst; Rails Contributor. linkedin.com/in/mohamedosamaa stackoverflow.com/cv/oss

Read More