Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was doing fine with default ssh port 22 on my remote server then i read somewhere if i change the port to 2222 at least i can stop some automated login attempt to my ssh server so i've decided to change the port on my server

What I've Changed

System: Ubuntu 8.04 32bits with sudo apt-get install ssh

vi /etc/ssh/sshd_config 

change port 22 to port 2222

/etc/init.d/sshd restart

After i changed and restarted sshd It can't seem to work, now Im locked out of it but im sure port is open;

to test it i use telnet to port 2222

telnet 2222 i get reply
SSH-2.0-OpenSSH_4.7p1 Debian-8ubuntu1.2

nmap port scan it nmap -p 2222

Starting Nmap 4.53 ( ) Interesting ports on (x.x.x.x): PORT STATE SERVICE

2222/tcp open  unknown

router: linksys 54GL router firmware: Firmware: DD-WRT v24-sp1 vpn

i used port forwarding to map router port 2222 to my pc's port 2222

only 1 user..

thanks to shuvalo

ssh -v -p 2222

joec@server:~$ ssh -v -p2222
OpenSSH_4.7p1 Debian-8ubuntu1.2, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to[] port 2222.
debug1: Connection established.
debug1: identity file /home/joec/.ssh/identity type -1
debug1: identity file /home/joec/.ssh/id_rsa type -1
debug1: identity file /home/joec/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.7p1 Debian-8ubuntu1.2
debug1: match: OpenSSH_4.7p1 Debian-8ubuntu1.2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.7p1 Debian-8ubuntu1.2
debug1: SSH2_MSG_KEXINIT sent
Connection closed by

I hope these helps

share|improve this question

migrated from Mar 10 '10 at 23:19

This question came from our site for professional and enthusiast programmers.

This looks like a duplicate of: [ssh connection stop at “debug1: SSH2_MSG_KEXINIT sent” ](…) – karafior Sep 27 '11 at 5:33

How are you sshing into the server? What command are you running / program are you using? Are you using Putty (Windows).

If you are using the ssh command line program, your ssh command should be

ssh -p 2222

unless you have edited ~/.ssh/config on the client.

share|improve this answer
i've used putty, secureCRT, ubuntu linux terminal from couple different PCs.. connection all got dropped – Anonymous Mar 10 '10 at 17:27

show output from ssh -v -p2222

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.