Freelancer's Playground! New knowledges every now and then

21Jul/092

Connect To SSH Server Using Configuration File

Everyday, I need to connect to multiple SSH server with custom installation that need me to specify options to command line in order to connect properly. For example, on server x, SSH is configured to listen to port 1234. While on server y, it's listening on port 2345. Now, imagine this, I need to open a terminal and type ssh -p1234 username@server_x each and every time I need to connect to it. It would be better if I can just type ssh server_x.

Fortunately, SSH client on linux has the ability to configure certain connection with alias. All we have to do is, fill in this configuration to ssh config file located in ~/.ssh/config. Here is an example on how to connect to server_x:

Host server_x
   Hostname 192.168.0.123
   Port 1234
   User sshuser

There, it is. You will just have to type ssh server_x and ssh will recognize it as ssh -p 1234 -u sshuser 192.168.0.123

  • http://www.mahesajenar.com/ Aryo Sanjaya

    Are you sure the port is not 3433? Please verify.

    *cling*

  • http://www.mahesajenar.com Aryo Sanjaya

    Are you sure the port is not 3433? Please verify.

    *cling*