Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Member
    Join Date
    Oct 2002
    Posts
    14

    Default Can't change SSH port???

    I was going through securing a brand new server with a fresh install of CentOS 4 and for some reason I cannot change my SSH port or it will fail. Only thing to get SSH back is to run the safesshrestart script from WHM.

    Currently there is no firewall installed, I was going down the list from the How to secure your server post so really not much has changed on this server minus the Tweak security and updating software on the server.

    I even copied the sshd_config from another server exactly and still when I try to restart SSH through WHM it fails.

    This is my first install of CentOS that I have set up; maybe there is something I don't know about it that is causing the issue.

    Any ideas?

  2. #2
    Member serversphere's Avatar
    Join Date
    Jan 2004
    Posts
    658

    Default

    The restart fails or SSH itself fails? Try flushing iptables?

  3. #3
    Member
    Join Date
    Oct 2002
    Posts
    14

    Default

    Quote Originally Posted by webtiva
    The restart fails or SSH itself fails? Try flushing iptables?
    The restart fails so in turn SSH fails.

    I'll give that a try, Thanks!

  4. #4
    Member
    Join Date
    Apr 2005
    Location
    Texas
    Posts
    63

    Default

    Copying an sshd_config from another server doesn't sound like the best idea. Why didn't you simply change the "Port" directive in the /etc/ssh/sshd_config file and perform a /etc/init.d/sshd restart ?

  5. #5
    Member
    Join Date
    Oct 2002
    Posts
    14

    Default

    Quote Originally Posted by xidica
    Copying an sshd_config from another server doesn't sound like the best idea. Why didn't you simply change the "Port" directive in the /etc/ssh/sshd_config file and perform a /etc/init.d/sshd restart ?

    Because that didn't work as stated in my first post. Also what's wrong with moving the config of the same version of SSH. I did that after all else failed so I really had nothing to lose since I did what you just said like 10 times over each time failing no matter what port I changed it to. Also they were identical except for the port changes and root perms.

  6. #6
    Member
    Join Date
    Jan 2005
    Posts
    1,880

    Default

    I too recently tried to change the SSH port on a new server and, try as I might, it just wouldn't work.

    I could change the port number correctly in sshd_config and could restart sshd fine but could never login on the newly chosen port.

    As it turns out only a selection of commonly used ports were open on the router at the data centre. Perhaps you have something similar going on.

  7. #7
    Member
    Join Date
    Oct 2002
    Posts
    14

    Default

    Quote Originally Posted by webignition
    I too recently tried to change the SSH port on a new server and, try as I might, it just wouldn't work.

    I could change the port number correctly in sshd_config and could restart sshd fine but could never login on the newly chosen port.

    As it turns out only a selection of commonly used ports were open on the router at the data centre. Perhaps you have something similar going on.

    I had thought this same thing, However when I have to use the command to recover SSH it usually ends up setting up on port 23. So I tried to use port 23 since that worked and was able to log in via Putty, and still SSH Fails to start.



    I've done this lots of times on lots of servers and I've never this issue.

  8. #8
    Super Moderator This forum account has been confirmed by cPanel staff to represent a vendor. chirpy's Avatar
    Join Date
    Jun 2002
    Location
    Go on, have a guess
    Posts
    13,495

    Default

    Are you sure that the RH lokkit firewall isn't installed - it often is on a new OS install. Just a thought to make sure that the following is indeed empty:

    iptables -L -n

    One thing to check is to have SSH running on port 22. Change the SSH port and stay logged in. Restart SSH and stay logged in. Then run:

    netstat -lpn

    and check that sshd is bound to both port 22 (your session) and also the new port that the new daemon is now running on. If it is bound to the new port, then it's going to either be iptables or something external to the server.
    Jonathan Michaelson

    Need your cPanel servers secured and tuned?
    cPanel Server Configuration, Security, Recovery and Antivirus/AntiSpam Services
    Developers of the most effective (and free) Firewall & Security Solution for cPanel Servers - csf
    http://www.configserver.com

Similar Threads & Tags
Similar threads

  1. How to change SSH login port, How to change SSH login port
    By Pvnallly in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 06-17-2011, 02:56 AM
  2. Change SSH Port
    By polkocholo in forum Security
    Replies: 9
    Last Post: 03-19-2011, 02:44 AM
  3. Change the SSH port?
    By mikelbeck in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 08-11-2006, 01:30 PM
  4. Change SSH port
    By ptez in forum cPanel and WHM Discussions
    Replies: 5
    Last Post: 06-11-2006, 01:08 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube