The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SSH On Random Port

Discussion in 'General Discussion' started by deadlock, Nov 1, 2006.

  1. deadlock

    deadlock Well-Known Member

    Joined:
    May 12, 2002
    Messages:
    54
    Likes Received:
    0
    Trophy Points:
    6
    When I try to run SSH on any other port than 22 (for security reasons), I can connect and everything works fine for a little while, but then after a couple of minutes the connection drops. I've tried various different random port numbers but it's always the same, I can't stay connected. On port 22 I can stay connected for ages without any problem but it keeps getting attacked so I want to change it, but I also want to be able to stay connected :( Has anyone else had this problem or can suggest a solution?
     
  2. Manuel_accu

    Manuel_accu Well-Known Member

    Joined:
    Jun 19, 2005
    Messages:
    191
    Likes Received:
    0
    Trophy Points:
    16
  3. deadlock

    deadlock Well-Known Member

    Joined:
    May 12, 2002
    Messages:
    54
    Likes Received:
    0
    Trophy Points:
    6
    Yes that's exactly what I do to change port. Like I said, I have no problem connecting on other ports but my problem is *STAYING* connected for any length of time.
     
  4. Anishts

    Anishts Active Member

    Joined:
    Oct 6, 2005
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    Hi

    If connection timed out error is coming try this.

    in /etc/ssh/ssh_config put this line..

    ServerAliveInterval 240
     
  5. Manuel_accu

    Manuel_accu Well-Known Member

    Joined:
    Jun 19, 2005
    Messages:
    191
    Likes Received:
    0
    Trophy Points:
    16
    Check the below parameter in your sshd_config file:

    #LoginGraceTime 2m

    if it is enable then comment it

    Thanks,
     
  6. deadlock

    deadlock Well-Known Member

    Joined:
    May 12, 2002
    Messages:
    54
    Likes Received:
    0
    Trophy Points:
    6
    LoginGraceTime was already commented; ServerAliveInterval 240 broke the server :(

    I had another idea, I thought maybe the firewall on my PC was the culprit so I tried disabling it but it made no difference.

    Any other ideas?
     
  7. mctDarren

    mctDarren Well-Known Member

    Joined:
    Jan 6, 2004
    Messages:
    664
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    New Jersey
    cPanel Access Level:
    Root Administrator
    Turn on keep alive in your SSH client?
     
  8. deadlock

    deadlock Well-Known Member

    Joined:
    May 12, 2002
    Messages:
    54
    Likes Received:
    0
    Trophy Points:
    6
    The connection drops when I'm right in the middle of doing something so that's not it, thanks anyway.
     
  9. SoftDux

    SoftDux Well-Known Member

    Joined:
    May 27, 2006
    Messages:
    983
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Johannesburg, South Africa
    cPanel Access Level:
    Root Administrator
    By default SSH runs on port 22 (mine is not on port 22), so the fact that it drops the connection on all other ports after a short while could either mean that other programs are trying to use those ports, or your'e firewall was set to close suspicious ports. Check the firewall rules, making sure the port in question is not being blocked, and that no other programs are trying to use the port you want to use. Try using a port in the high ranges, say 4000 or something
     
  10. xerophyte

    xerophyte Well-Known Member

    Joined:
    Mar 16, 2003
    Messages:
    216
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Canada
    I agree with softdux, seems like your firewall is blocking your port, check with firewall configuration and make sure no other program use same port you are using it for ssh
     
  11. randomuser

    randomuser Well-Known Member

    Joined:
    Jun 25, 2005
    Messages:
    147
    Likes Received:
    0
    Trophy Points:
    16
    1. connect to sshd on the alternate port
    2. from the computer you connected from, start tcpdump or windump and log the complete packets (like: tcpdump -Xnvvs 1500 >> out)
    3. when you get disconnected, ctrl+c tcpdump/windump
    4. check to see where the disconnect came from

    That would be a good start.

    Also, is there an IPS anywhere in the mix between you and the server you're connecting to?
     
  12. Anishts

    Anishts Active Member

    Joined:
    Oct 6, 2005
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    Hi

    Sorry I forgot to tell one thing you have to add this in client machine

    in /etc/ssh/ssh_config put this line..

    ServerAliveInterval 240
     
  13. sierrablue

    sierrablue Member

    Joined:
    Aug 30, 2005
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    I had similar problem. SIM (system integrity monitor) was checking if sshd was up and constantly restarting sshd.

    Editing SSH port in /usr/local/sim/conf.sim solved my problem.
     
  14. eth00

    eth00 Well-Known Member
    PartnerNOC

    Joined:
    Mar 30, 2003
    Messages:
    723
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    NC
    cPanel Access Level:
    Root Administrator
    To make sure it is that you can look at the sim.log, it should be reporting it in the log when it is restarted.
     
Loading...

Share This Page