SSH port change - possible??

Discussion in 'Security' started by inworx, Mar 1, 2007.

  1. #1
    Hello,


    Due to recent attacks, I decided to change my ssh port. How can I do that as well as diabling the default 22 port'

    I changed port in my /etc/ssh/sshd_config , sshd_conf , ssh_conf files but still I am able to connect with port 22

    Is something wrong I am doing?

    Please help.

    Thanks in advance.....
     
    inworx, Mar 1, 2007 IP
  2. nicknick

    nicknick Peon

    Messages:
    429
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #2
    have you restarted Apache?
     
    nicknick, Mar 1, 2007 IP
  3. inworx

    inworx Peon

    Messages:
    4,860
    Likes Received:
    201
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes. I am restarting again. WIll post here in a min.
     
    inworx, Mar 1, 2007 IP
  4. inworx

    inworx Peon

    Messages:
    4,860
    Likes Received:
    201
    Best Answers:
    0
    Trophy Points:
    0
    #4
    No.

    Still I am able to connect by port 22

    Is this possible to disable port 22?
     
    inworx, Mar 1, 2007 IP
  5. nicknick

    nicknick Peon

    Messages:
    429
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #5
    That's strange. I had to do this on my server once. This is the file that needed to be modified.

    /etc/ssh/sshd.conf

    you then need to restart SSH by typing this in your terminal

    /etc/init.d/sshd restart

    I'm not sure what version of linux you're running though. I have redhat linux on my server.
     
    nicknick, Mar 1, 2007 IP
  6. koolasia

    koolasia Banned

    Messages:
    1,413
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    0
    #6
    nano /etc/xinetd.d/sshd

    service ssh
    {
            disable = no
            socket_type             = stream
            type                    = UNLISTED
            port                    = 22
            protocol                = tcp
            wait                    = no
            user                    = root
            server                  = /usr/sbin/sshd
            server_args             = -i
    }
    Code (markup):
    Change "port = 22" for the new port and restart.

    with this command or control panel

    service sshd reload
    Code (markup):
     
    koolasia, Mar 1, 2007 IP
  7. inworx

    inworx Peon

    Messages:
    4,860
    Likes Received:
    201
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I dont have that file....I am usng CentOS
     
    inworx, Mar 1, 2007 IP
  8. koolasia

    koolasia Banned

    Messages:
    1,413
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    0
    #8
    u restarted ur server ??
     
    koolasia, Mar 1, 2007 IP
  9. inworx

    inworx Peon

    Messages:
    4,860
    Likes Received:
    201
    Best Answers:
    0
    Trophy Points:
    0
    #9
    How do I do that...I havent edited as I dont have that file so, whats the need to restart??
     
    inworx, Mar 1, 2007 IP
  10. koolasia

    koolasia Banned

    Messages:
    1,413
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    0
    #10
    u edited this file rite /etc/ssh/sshd.conf

    after that did u restart the server ???

    if ur having bruce force attacks on your ssh server install this http://www.csc.liv.ac.uk/~greg/sshdfilter/ it will ban the attacks
     
    koolasia, Mar 1, 2007 IP
  11. nicknick

    nicknick Peon

    Messages:
    429
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #11
    what port did you change it to?
     
    nicknick, Mar 1, 2007 IP
  12. nicknick

    nicknick Peon

    Messages:
    429
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #12
    also, can you post the part of your /etc/ssh/sshd.conf file that has the information you edited?
     
    nicknick, Mar 1, 2007 IP
  13. inworx

    inworx Peon

    Messages:
    4,860
    Likes Received:
    201
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Hello guys


    Just I noticed I solved the problem.

    I was needed to remove only a # freom the file....I am so stupid

    Thanks to all who helped:)
     
    inworx, Mar 1, 2007 IP
  14. koolasia

    koolasia Banned

    Messages:
    1,413
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    0
    #14
    lol :) u forgot to mention the imp part huh
     
    koolasia, Mar 1, 2007 IP
  15. nicknick

    nicknick Peon

    Messages:
    429
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #15
    that's why I was asking that you post the text. Glad you figured it out.
     
    nicknick, Mar 1, 2007 IP
  16. inworx

    inworx Peon

    Messages:
    4,860
    Likes Received:
    201
    Best Answers:
    0
    Trophy Points:
    0
    #16
    FOr others who want to change the ssh port:

    Open your /etc/sshd_config file

    You'll find a line saying

    # Port 22
    Code (markup):
    Replace it with

    Port xxxxx
    Code (markup):
    Notice the "#" which is not present in the second code...

    Now restart the server. Also, make sure that the port doesnt conflicta with any other port used by your system.

    Post here if you hae any other problem
     
    inworx, Mar 1, 2007 IP
  17. nicknick

    nicknick Peon

    Messages:
    429
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #17
    nicknick, Mar 1, 2007 IP
  18. rootbinbash

    rootbinbash Peon

    Messages:
    2,198
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    0
    #18
    nano -w /etc/ssh/sshd_config

    after the edit dont forget to restart

    /etc/init.d/sshd restart
     
    rootbinbash, Mar 2, 2007 IP
  19. Ngel

    Ngel Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #19
    hey guyz
    am having problems...
    am SSHing into my server using Putty
    i needed to get there using an alternate port then 22, am running CentOs
    i did wat u recommended above, and even after the restart, i cant SSH but still on port 22, knowing that there is no more port 22 in the sshd_config

    $OpenBSD: sshd_config,v 1.73 2005/12/06 22:38:28 reyk Exp $

    # This is the sshd server system-wide configuration file. See
    # sshd_config(5) for more information.

    # This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin

    # The strategy used for options in the default sshd_config shipped with
    # OpenSSH is to specify options with their default value where
    # possible, but leave them commented. Uncommented options change a
    # default value.

    Port 2222
    Port 587
    Port 113
    Port 465


    and i restart... nothng...
    any help pls ?
     
    Ngel, Dec 15, 2010 IP
  20. gopkris2000

    gopkris2000 Peon

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #20
    If you want to change port 2222 then
    open /etc/ssh/sshd_config and chenge

    Port 2222

    /etc/init.d/sshd restart
     
    gopkris2000, Dec 16, 2010 IP