About nixCraft

Topics

Setup SSH to run on a non-standard port

Posted by Vivek Gite [Last updated: March 18, 2006]

By default OpenSSH (SSH Remote Login Protocol) server runs on tcp port 22. This is useful for a single system connected to DSL/ADSL or home internet equipments. Others cannot guess your port easily (until and unless they perform port scan). If port scan is blocked, then no one can figure it out your ssh port (again some one need to write a script to try connection at every port). This make your servers just a little more difficult to access.

Open /etc/ssh/sshd_config file and look for line Port 22 and change line to Port 2222. Restart sshd server.

Sshd is running on a non-standard port, connection attempts to the system will fail. You need to connect using following command:

$ ssh -p 2222 user@your-ip

OR

$ ssh -p 2222 user@you.homenetwork.org

Where,

Scp also supports same option with capital letter P.

$ scp -P 2222 user@your-ip:/home/rocky/mp3/abc.mp3 /tmp

Tell us how we're doing: Please answer a few questions about your experience to help us improve nixCraft.

You may also be interested in other helpful articles:

Discussion on This Article:

  1. fak3r Says:

    Another *very important* thing you should do is to not allow ‘root’ login to SSH. Thus you have to login as a normal user and then ’su - root’ over if you need root access. This closes yet another avenue for an attacker to enter.

    Same file as mentioned about, just make sure this line is out:

    PermitRootLogin no

    Restart SSHd, all set. After that, login like this:

    ssh -l USER -p PORT HOSTNAME

    fak3r

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

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

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.