Find the answer to your Linux question:
Results 1 to 10 of 10
hello everyone, I changed the default port for ssh but now I cant seem to be able to connect to my virtualised CentOS server with putty. I get connection refused. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    RJ.
    RJ. is offline
    Just Joined!
    Join Date
    Jan 2012
    Posts
    13

    putty "connection refused"


    hello everyone,

    I changed the default port for ssh but now
    I cant seem to be able to connect to my virtualised CentOS server with putty.

    I get connection refused.

    I turned off iptables and it worked.
    I tried to add this new port to iptables, it does show in the list of INPUT, but I still cant connect.

    is there something I forgot to do?

    I apologise if this has been asked a lot already but i couldnt find anything about it.
    Last edited by RJ.; 03-06-2012 at 07:01 PM.

  2. #2
    Just Joined!
    Join Date
    Mar 2012
    Posts
    18
    Did you activate the SSH demon on your server?

    chkconfig sshd on
    service sshd start

  3. #3
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,677
    If turning off IPTABLES it work then I would need to know what your rules look like to say why the firewall is blocking the connection.

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Feb 2011
    Posts
    21
    Does the ssh daemon need to be listening on a port other than 22?

  6. #5
    RJ.
    RJ. is offline
    Just Joined!
    Join Date
    Jan 2012
    Posts
    13
    Its definitely iptables

    I included the rule:

    ACCEPT tcp anywhere anywhere tcp dpt:11576

    Still putty will not connect to it.

    And , yes, I did change the default port at /etc/ssh/sshd_config to the same port.

    im working behind a different pc now and now i get the same error with iptables off :S.

  7. #6
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,677
    If you are getting the same error with iptables turned off then I would not think it is iptables that is causing your issues.
    What is the output from;

    Code:
    service sshd status
    Also can you post /etc/sysconfig/iptables Just to be sure nothing would be causing an issue there too.
    You can PM your rules to me if you do not want to post them on a public forum.

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

  8. #7
    RJ.
    RJ. is offline
    Just Joined!
    Join Date
    Jan 2012
    Posts
    13
    Quote Originally Posted by Lazydog View Post
    Also can you post /etc/sysconfig/iptables Just to be sure nothing would be causing an issue there too.You can PM your rules to me if you do not want to post them on a public forum.
    thats okay, its just a VM anyway. Just for testing and learing. Here's the content of Iptables:

    Chain INPUT (policy ACCEPT)
    target prot opt source destination
    ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
    ACCEPT icmp -- anywhere anywhere
    ACCEPT all -- anywhere anywhere
    ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
    REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
    ACCEPT tcp -- anywhere anywhere tcp dpt:11576

    Chain FORWARD (policy ACCEPT)
    target prot opt source destination
    REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

    Chain OUTPUT (policy ACCEPT)
    target prot opt source destination
    ACCEPT tcp -- anywhere anywhere tcp dpt:11576

    11576 is the new port im using , or trying to use, for ssh.

    I tried it on a actual network this time and it does work with iptables turned off but not with ift turned on.
    Last edited by RJ.; 03-07-2012 at 08:57 AM.

  9. #8
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,677
    Quote Originally Posted by RJ. View Post
    REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
    ACCEPT tcp -- anywhere anywhere tcp dpt:11576
    This is why it is not working. You have to place the line to allow port 11576 before the reject line.
    Rules are read from top to bottom in order first match is executed thus every after REJECT is never seen.

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

  10. #9
    RJ.
    RJ. is offline
    Just Joined!
    Join Date
    Jan 2012
    Posts
    13
    Thank you very much

    That did it.

  11. #10
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,677
    Glad I could help.

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

Posting Permissions

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