How to change default SSH port on OpenSSH?


How to change default SSH port on OpenSSH?


Login to you SSH,
         

  1.   SSH into your server as the root user.
            ssh root@ -p 2200

       2. You  can find the OpenSSH config file at
         
            /etc/ssh/sshd_config
            
        3. You need to edit the file "sshd_config" (Make sure you have logged in with the root access.)

             Locate the Line with has "# Port 22"
            Change the number part to some other number you want to have.
            After changing make sure you save the config.

         4. Make sure you restart the SSH daemon use
           
             /etc/init.d/sshd restart
             OR
             service sshd restart

         5. Now test your configuration with the below command,
             
             # netstat -tulpn |grep sshd
             tcp     0     0  0.0.0.0:XXXX     0.0.0.0:*   LISTEN   5672/sshd 
             tcp     0     0  :::XXXX              :::*    LISTEN   5672/sshd

           6. Now to connect to the new port use the below command,

             sftp -oPort=XXXX user@XX.XXX.XXX.XXX:/myhome/something

Post a Comment

0 Comments