How to change the ssh port for a specific ip address?

26,110

Solution 1

The most comfortable solution in long-term is to add the host to your ~/.ssh/config file. Edit/create the file and add:

 Host home
 User root
 Hostname myipaddress
 Port 6091

Then you can simply connect to home with:

 ssh home

More info

Solution 2

ssh -p 6091 root@myipaddress

-p port
             Port to connect to on the remote host.  This can be specified on a per-host basis in the configuration file.

Solution 3

Add this to your ~/.ssh/config

 Host special
    HostName special.myjob.com
    Port 22000
    User fooey

Now you can just run:

 ssh special

to get

 ssh -p 22000 [email protected]

More ssh tips at:

http://nerderati.com/2011/03/17/simplify-your-life-with-an-ssh-config-file/

Share:
26,110

Related videos on Youtube

Tung Can
Author by

Tung Can

Updated on September 18, 2022

Comments

  • Tung Can
    Tung Can over 1 year

    I get the trouble with putty, so I prefer using shell (linux) to access server via ssh, my ip address has alter port for ssh is 6091, so is there anyway to access server via ssh by command

    ssh root@myipaddress
    

    Because I have many server has default ssh port is 22, so I just want to change port to specific ip address.

  • Mikko Ohtamaa
    Mikko Ohtamaa almost 10 years
    Don't forget to mark the answer as "correct" on serverfault.com if you think it is the best fit to your question :)