Centos – Trouble changing SSH port

centosportssh

I'm running a CENTOS web server with WHM and CSF firewall. I'm trying to change SSH from the default port. I've opened up the port in CSF and modified /etc/ssh/sshd_config uncommenting the port line and changing it to the port I want it to be on. I've then restarted SSH using WHM and command line and it restarts. However when it restarts it's still using the default port of 22. What am I doing wrong?

Settings from sshd_config file:

# Host *
#   ForwardAgent no
#   ForwardX11 no
#   RhostsRSAAuthentication no
#   RSAAuthentication yes
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   GSSAPIKeyExchange no
#   GSSAPITrustDNS no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/identity
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
Port 2222
#   Protocol 2,1
#   Cipher 3des
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
Host *

Then here's the copy from my console so you can see what I ran:

root@vps1 [~]# cd /etc/ssh
root@vps1 [/etc/ssh]# vi ssh_config
root@vps1 [/etc/ssh]# /etc/init.d/sshd restart
Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]
root@vps1 [/etc/ssh]#

I then ran netstat -tuplen to check the port it was running on:

tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      0          36862521   8315/sshd

Still running on port 22.

Best Answer

What you have in your question is not a sshd_config that is a ssh_config.
You need to edit sshd_config instead and restart sshd afterwards.

ssh_config is the client configuration and has no effect on daemon settings.