SSH on Alternate Ports

If you want to run SSH on a port other than the standard port 22, you can make the following change.

$ sudo vi /etc/ssh/ssh_config:

# Comment out or changeg the Port directive
#Port 22
Port 9022

Now, restart sshd.

$ sudo /sbin/service sshd restart

For subversion to work on this new port, edit ~/.ssh/config on your local system and create an entry like this:

Host youraccount.railsmachina.com
  Port 9022

You should now be able to ssh to your server or run svn update as if nothing had changed.

If you want to get fancy, you can create an easy alias for your server:


Host myserver
Port 9022
User deploy
HostName youraccount.railsmachina.com

Now you can connect to the server with ‘ssh myserver’- the username, port, and hostname will be read from your ssh config. If you do this be sure to relocate your svn repository on your local dev system to the new, shorter URL or it may not work:

cd /path/to/project
svn switch --relocate svn+ssh://deploy@youraccount.railsmachina.com/var/www/apps/yourapp/repos/trunk svn+ssh://myserver/var/www/apps/yourapp/repos/trunk
Meta