Unable to ssh to server remotely

Discussion in 'Server Operation' started by Tastiger, Apr 27, 2017.

  1. Tastiger

    Tastiger Member

    In the process of moving but have had a holdup but because of ISP server is now located at new residence whilst we are stuck here for another week.
    Server is setup as per https://www.howtoforge.com/tutorial...l-pureftpd-bind-postfix-doveot-and-ispconfig/
    My problem is I cannot contact the server via port 22 on via putty or WinSCP, I can reach the sites via FTP but not the server, this wasn't an issue when the server and my work station were on the same network as I used the internal IP address to for all ssh actions.
    Looking at Webmin SSH Login it tells me : There is no SSH server running on port 22.
    However using Webmin's command shell I get
    Code:
    > ps -A | grep sshd
    1548 ?        00:00:00 sshd
    and
    Code:
    > sudo ss -lnp | grep sshd
    tcp    LISTEN     0      128       *:22                    *:*                   users:(("sshd",pid=1548,fd=3))
    tcp    LISTEN     0      128      :::22                   :::*                   users:(("sshd",pid=1548,fd=4))
    as well as
    Code:
    > sudo iptables --list
    Chain INPUT (policy ACCEPT)
    target prot opt source destination
    f2b-dovecot-pop3imap tcp -- anywhere anywhere multiport dports pop3,pop3s,imap2,imaps
    f2b-pureftpd tcp -- anywhere anywhere multiport dports ftp
    f2b-postfix-sasl tcp -- anywhere anywhere multiport dports smtp
    f2b-sshd tcp -- anywhere anywhere multiport dports ssh
    
    Chain FORWARD (policy ACCEPT)
    target prot opt source destination
    
    Chain OUTPUT (policy ACCEPT)
    target prot opt source destination
    
    Chain f2b-dovecot-pop3imap (1 references)
    target prot opt source destination
    RETURN all -- anywhere anywhere
    
    Chain f2b-postfix-sasl (1 references)
    target prot opt source destination
    RETURN all -- anywhere anywhere
    
    Chain f2b-pureftpd (1 references)
    target prot opt source destination
    RETURN all -- anywhere anywhere
    
    Chain f2b-sshd (1 references)
    target prot opt source destination
    REJECT all -- 10.0.0.138 anywhere reject-with icmp-port-unreachable
    RETURN all -- anywhere anywhere
    Is it the REJECT all -- 10.0.0.138 that is the issue? (10.0.0.138 is the gateway)

    If so how to fix or otherwise it's obvious that I have have something configured wrong but as to what I am clueless and need to get it working for other times when I am away from the server location
     
    Last edited: Apr 27, 2017
  2. ahrasis

    ahrasis Member

    Are you trying to access the server using ssh [email protected]: port or [email protected]: port?
     
  3. Andhikaup

    Andhikaup New Member

    above the line
    REJECT all -- 10.0.0.138 anywhere reject-with icmp-port-unreachable

    put this line
    -A INPUT -p tcp -m tcp --dport 10000 -j ACCEPT
    -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
     
  4. Tastiger

    Tastiger Member

    [​IMG]
     
  5. Tastiger

    Tastiger Member

    which file do I have to edit?
    I'll have to download it via the file browser in Webmin edit then upload and reboot I guess?
     
  6. Andhikaup

    Andhikaup New Member

    what distro's did you use?
    you need to edit the iptabes config file
    if its centos you can edit this file /etc/sysconfig/iptables
    don't forget to restart youre firewall after editing
    # /etc/init.d/iptables restart
     
  7. Tastiger

    Tastiger Member

    Update - just by chance I re-ran
    iptables --list
    and the line REJECT all -- 10.0.0.138 anywhere reject-with icmp-port-unreachable wasn't there this time so I tried Winscp and lo and behold - it connected OK so something strange happening, that's for sure
     
  8. Tastiger

    Tastiger Member

    as above - Ubuntu 16.04
     
  9. Andhikaup

    Andhikaup New Member

    Are you sure youre not using "iptables -F"
    if you restart the firewall did and do the "iptables -L" does the rule still the same?
    my suggestion is still you need to check the firewall configuration for sure
     
  10. Tastiger

    Tastiger Member

    no using iptables --list
    Code:
    > iptables -L
    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination        
    f2b-dovecot-pop3imap  tcp  --  anywhere             anywhere             multiport dports pop3,pop3s,imap2,imaps
    f2b-pureftpd  tcp  --  anywhere             anywhere             multiport dports ftp
    f2b-postfix-sasl  tcp  --  anywhere             anywhere             multiport dports smtp
    f2b-sshd   tcp  --  anywhere             anywhere             multiport dports ssh
    
    Chain FORWARD (policy ACCEPT)
    target     prot opt source               destination        
    
    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination        
    
    Chain f2b-dovecot-pop3imap (1 references)
    target     prot opt source               destination        
    RETURN     all  --  anywhere             anywhere           
    
    Chain f2b-postfix-sasl (1 references)
    target     prot opt source               destination        
    RETURN     all  --  anywhere             anywhere           
    
    Chain f2b-pureftpd (1 references)
    target     prot opt source               destination        
    RETURN     all  --  anywhere             anywhere           
    
    Chain f2b-sshd (1 references)
    target     prot opt source               destination        
    RETURN     all  --  anywhere             anywhere         
    It started working for a while and Ubuntu did some updates and closed connection after the
    Code:
    w: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
    error appeared now I can't connect again, seems as though I will have to get your suggestions and pay a visit to the server tomorrow and access it directly
     
  11. Tastiger

    Tastiger Member

    update
    managed to restart the firewall via Webmin and now it's connecting again :rolleyes:
    .... and stopped connecting again
    So appears to be an intermittent issue with the firewall and I'm way out of my depth
     
    Last edited: Apr 28, 2017
  12. Andhikaup

    Andhikaup New Member

  13. Tastiger

    Tastiger Member

    When I access Linux Firewall via webmin I get the following:-
    [​IMG]
    Not wanting to mess things up from the original setup as per the Perfect Server tutorial, is there any danger in me creating the file as suggested, disabling existing script and enabling firewall at boot time?

    If the answer is go ahead how do I disable existing script?
     
    Last edited: Apr 28, 2017
  14. Andhikaup

    Andhikaup New Member

    If you prefer using webmin for managing firewal then don't convert it. Be sure to allow ssh (22) and webmin (10000) before you apply the the firewall in webmin.

    Don't forget to put your new rule above the reject all rule
     

Share This Page