port forwarding broken

Discussion in 'Server Operation' started by satimis, Jul 18, 2008.

  1. satimis

    satimis Member

    Hi folks,


    Ubuntu LAMP 6.06 amd64


    The captioned server can be ssh connected on local pc running;

    $ ssh -p 2222 192.168.0.52


    It has been working couple months without problem. Just discover it doesn't work.

    $ ssh -p 2222 192.168.0.52
    Code:
    Bad port ' 2222'
    

    On /etc/ssh/sshd_config
    Code:
    # What ports, IPs and protocols we listen for
    Port 2222
    Protocol 2
    ....
    
    I haven't made any change on this file.


    Another strange thing is /var/log/sshd.log disappeared.


    $ sudo locate .log | grep sshd
    No printout


    Please help. TIA


    B.R.
    satimis
     
  2. chipsafts

    chipsafts New Member

    is the sshd running ?
     
  3. satimis

    satimis Member

    Hi chipsafts,


    $ ps aux | grep sshd
    Code:
    root      4194  0.0  0.1  25772  1164  ?    Ss  23:51  0.00  /usr/sbin/sshd
    satimis  4595  0.0  0.0   3940    896 tty1 R+  23:50  0:00  grep sshd
    

    $ sudo /etc/init.d/ssh reload
    Code:
     * reloading OpenBSD ......... [ok ]
    

    No improvement. Still can't connect.


    B.R.
    satimis
     
  4. ralic

    ralic New Member

    Has something else taken that port on the server?

    What does 'sudo netstat -tnap' show?
     
    Last edited: Jul 18, 2008
  5. satimis

    satimis Member

    Hi ralic,


    To my surprise after switching off the server several hours it is working again now.

    $ ssh -p 2222 192.168.0.52
    Code:
    The authenticity of host '192.168.0.52 (192.168.0.52)' can't be established.
    RSA key fingerprint is 87:8b:d7:e3:12:f7:8d:76:fe:2d:f7:64:f6:93:fc:a0.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '192.168.0.52' (RSA) to the list of known hosts.
    Ubuntu 6.06.2 LTS
    Password: 
    Linux satimis.com 2.6.15-52-amd64-server #1 SMP Fri Jul 11 13:33:35 UTC 2008 x86
    _64 GNU/Linux
    satimis.com 2.6.15-51-amd64-server #1 SMP Tue Feb 12 17:08:38 UTC 2008 x86_64 GN
    U/Linux
    
    The programs included with the Ubuntu system are free software;
    the exact distribution terms for each program are described in the
    individual files in /usr/share/doc/*/copyright.
    
    Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
    applicable law.
    

    What I have done before;

    1)
    deleting the content on;

    ~.ssh/know-hosts

    but without reboot afterwards.


    2)
    changing Port 2222 to;

    Port 22

    $ sudo /etc/init.d/sshd reload


    3)
    Tried to ssh-connect the server;

    $ ssh -p 22 192.168.0.52
    Code:
    Bad port ` 22`
    
    Failed


    4)
    Changing Port 22 back to;

    Port 2222

    then;

    $ sudo /etc/init.d/sshd reload

    Still failed to ssh connect the server.


    But I can't find /var/log/sshd.log

    $ sudo locate .log | grep sshd
    No printout


    $ sudo netstat -tnap
    Code:
    Password:
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name   
    tcp        0      0 0.0.0.0:2401            0.0.0.0:*               LISTEN     4261/xinetd         
    tcp        0      0 0.0.0.0:40385           0.0.0.0:*               LISTEN     -                   
    tcp        0      0 0.0.0.0:2049            0.0.0.0:*               LISTEN     -                   
    tcp        0      0 0.0.0.0:993             0.0.0.0:*               LISTEN     3876/cyrmaster      
    tcp        0      0 0.0.0.0:643             0.0.0.0:*               LISTEN     4277/rpc.statd      
    tcp        0      0 0.0.0.0:995             0.0.0.0:*               LISTEN     3876/cyrmaster      
    tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN     3972/mysqld         
    tcp        0      0 0.0.0.0:110             0.0.0.0:*               LISTEN     3876/cyrmaster      
    tcp        0      0 0.0.0.0:143             0.0.0.0:*               LISTEN     3876/cyrmaster      
    tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN     3474/portmap        
    tcp        0      0 127.0.0.1:2000          0.0.0.0:*               LISTEN     3876/cyrmaster      
    tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN     4207/vsftpd         
    tcp        0      0 192.168.0.52:53         0.0.0.0:*               LISTEN     3806/named          
    tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN     3806/named          
    tcp        0      0 0.0.0.0:886             0.0.0.0:*               LISTEN     4099/rpc.mountd     
    tcp        0      0 192.168.0.52:631        0.0.0.0:*               LISTEN     3843/cupsd          
    tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN     3843/cupsd          
    tcp        0      0 0.0.0.0:8888            0.0.0.0:*               LISTEN     4315/(squid)        
    tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN     4166/master         
    tcp6       0      0 :::993                  :::*                    LISTEN     3876/cyrmaster      
    tcp6       0      0 :::995                  :::*                    LISTEN     3876/cyrmaster      
    tcp6       0      0 :::2222                 :::*                    LISTEN     4195/sshd           
    tcp6       0      0 :::110                  :::*                    LISTEN     3876/cyrmaster      
    tcp6       0      0 :::143                  :::*                    LISTEN     3876/cyrmaster      
    tcp6       0      0 :::80                   :::*                    LISTEN     4361/apache2        
    tcp6       0      0 :::25                   :::*                    LISTEN     4166/master         
    tcp6       0      0 :::443                  :::*                    LISTEN     4361/apache2        
    tcp6       0 144 ::ffff:192.168.0.52:2222 ::ffff:192.168.0.10:57324 ESTABLISHED4441/sshd: satimis  
    

    B.R.
    satimis
     
  6. ralic

    ralic New Member

    Definitely something funny going on here. The error 'Bad port' indicates that the port is out of range (>0 and <=65535). The output you are posting:
    Code:
    $ ssh -p 22 192.168.0.52
    Bad port ` 22`
    
    shows a space between the first ` and the first number of the port 22. It's the same in your earlier post. Basically this indicates that the port is not a number any longer and is being interpreted by ssh as a character string and further explains why it is 'out of range'.

    I'm not sure how that can happen though. But if you can find it and remove the space, I think it will solve your problem.

    Is your shell getting in the way somehow? What about trying: ssh -p "2222" 192.168.0.52? I really can't offer any ideas as to why the space between the -p and the 22 would become literal... Maybe ssh has been aliased?

    The sshd related output can be found in /var/log/auth.log. There isn't a specific sshd log file.
     
    Last edited: Jul 19, 2008
  7. satimis

    satimis Member

    Hi ralic,


    Really something has been happened here. Its cause is known to me.

    I have been running;
    Code:
    $ ssh -p 2222 192.168.0.52
    
    to connected the remote LAMP server for couple months without problem.


    Just tried;
    Code:
    $ ssh -p2222 192.168.0.52
    
    It also works. Now both of them can work w/o problem.

    I have changed back on /etc/ssh/sshd_config ;
    Code:
    # What ports, IPs and protocols we listen for
    Port 2222
    ...
    
    So Port 22 won't work anymore.


    $ tail /var/log/auth.log
    Code:
    Jul 20 20:10:23 satimis sshd[4444]: (pam_unix) session closed for user satimis
    Jul 20 20:10:46 satimis sshd[4463]: Accepted keyboard-interactive/pam for satimis from 192.168.0.10 port 60055 ssh2
    Jul 20 20:10:46 satimis sshd[4466]: (pam_unix) session opened for user satimis by (uid=0)
    Jul 20 20:10:58 satimis sshd[4466]: (pam_unix) session closed for user satimis
    Jul 20 20:11:01 satimis CRON[4485]: (pam_unix) session opened for user root by (uid=0)
    Jul 20 20:11:01 satimis CRON[4485]: (pam_unix) session closed for user root
    Jul 20 20:12:01 satimis CRON[4488]: (pam_unix) session opened for user root by (uid=0)
    Jul 20 20:12:01 satimis CRON[4488]: (pam_unix) session closed for user root
    Jul 20 20:12:33 satimis sshd[4491]: Accepted keyboard-interactive/pam for satimis from 192.168.0.10 port 60057 ssh2
    Jul 20 20:12:33 satimis sshd[4494]: (pam_unix) session opened for user satimis by (uid=0)
    
    I got it. Thanks.


    On another Ubuntu LAMP server 7.04 amd64 here it is;
    /var/log/sshd.log


    Therefore I thought sshd.log was missing.


    B.R.
    satimis
     

Share This Page