Results 1 to 10 of 10
  1. #1
    Join Date
    Jan 2006
    Posts
    264

    Can't close Port 22

    I recently aqcuired a VPS. I'm running CentOS 5.

    I cannot close port 22. I logged in and edited the /etc/ssh/sshd_config file and changed the Port 22 to a high random number.

    It works... I can SSH using the new port, but I can also still SSH under port 22, and it is not listed in my sshd_config file anymore.

    I restarted 'service sshd restart', and I manually stopped it and started it again, and nothing is working.

    Can anyone tell me where to go to fix this issue please?

  2. #2
    Join Date
    Feb 2003
    Location
    North Hollywood, CA
    Posts
    2,554
    Did you logout of your session?

    netstat -natp
    Remote Hands and Your Local Tech for the Los Angeles area.

    (310) 573-8050 - LinkedIn

  3. #3
    Join Date
    Jan 2006
    Posts
    264
    Quote Originally Posted by Jeremy View Post
    Did you logout of your session?

    netstat -natp
    when I was done, I typed 'exit'.

    I just typed what you suggested and this is what it returned (only the applicable line that is):

    tcp 0 0 :::22 :::* LISTEN 9581/sshd

    There is another line with sshd on it and it lists the correct port (the one that I'm logged into now).

  4. #4
    Join Date
    Jan 2006
    Posts
    264
    I ran: service sshd stop

    then: netstat -natp

    It relisted the netstat items and the port 22 was still listening. however, the port that I changed it to isn't listening anymore.

  5. #5
    Join Date
    Jul 2007
    Posts
    55
    Log out completely from your server.
    And fire up a new session. Try that.
    L
    I work with a cup of tea, prefer green tea.

  6. #6
    Join Date
    Jan 2006
    Posts
    264
    Quote Originally Posted by Tealeaf View Post
    Log out completely from your server.
    And fire up a new session. Try that.
    I did that about 4 times. Still open.

  7. #7
    Join Date
    Feb 2003
    Location
    North Hollywood, CA
    Posts
    2,554
    Interesting.

    Anyone else connected to the sshd?

    Only if your local, trying killing the sshd then check if anything is on port 22

    ps aux|grep ssh

    then kill the PID
    should list whats running or you can use lsof.

    If your not local, try a reboot. make sure the config is correct.

    btw what file are you editing?
    Remote Hands and Your Local Tech for the Los Angeles area.

    (310) 573-8050 - LinkedIn

  8. #8
    Join Date
    Jan 2006
    Posts
    264
    I edited /etc/ssh/sshd_config

    I chaged Port 22 to Port 5555 (for example).


    And no... No one else is logged in.

    I haven't tried rebooting the server in fear that I might mess something up. I have only restarted the service.

  9. #9
    Join Date
    Jun 2003
    Posts
    364
    Hi,

    Please make sure you are indeed looking at /etc/ssh/sshd_config and not /etc/ssh/ssh_config as this is a common mistake.

    Also make sure that the sshd process is actually restarting by checking the pid and start date. Do not kill anything but the process that is your ssh session.

    If that is not the issue, I would suggest posting the entire config file (eg. pastebin.ca)

  10. #10
    Join Date
    Jan 2006
    Posts
    264
    It was definitely the right file (/etc/ssh/sshd_config), I just double checked it.

    I installed apf and it will no longer allow me to login under port 22.

    I don't know if that is the correct way to fix it, but it seems to have worked.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •