0

I have two computers, one is running Debian GNU/Linux 9 and the other Ubuntu 18.04.1 LTS. I have installed openssh on both computers.

sudo apt install openssh-client
sudo apt install openssh-server

Now, I am able to use ssh to connect from Debian to Ubuntu, but not from Ubuntu to Debian.

On the Debian computer

nmap localhost

outputs:

Starting Nmap 7.40 ( https://nmap.org ) at 2019-01-24 14:39 CET
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00010s latency).
Other addresses for localhost (not scanned): ::1
Not shown: 999 closed ports
PORT   STATE SERVICE
22/tcp open  ssh

Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds

I have also tried running

sudo ufw allow ssh

on the Debian computer.

What should I do to be able to access either computer from the other?


Edited in responce to comments

Running netstat -l on the debian server outputs:

b1012@debian:~$ netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 localhost:5939          0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN     
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN     
udp        0      0 0.0.0.0:mdns            0.0.0.0:*                          
udp        0      0 0.0.0.0:40272           0.0.0.0:*                          
udp        0      0 0.0.0.0:57967           0.0.0.0:*                          
udp        0      0 0.0.0.0:bootpc          0.0.0.0:*                          
udp6       0      0 [::]:mdns               [::]:*                             
udp6       0      0 [::]:41052              [::]:*                             
raw6       0      0 [::]:ipv6-icmp          [::]:*                  7          
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ACC ]     STREAM     LISTENING     19723    /run/user/1000/pulse/native
unix  2      [ ACC ]     STREAM     LISTENING     15627    /run/uuidd/request
unix  2      [ ACC ]     STREAM     LISTENING     15630    /var/run/avahi-daemon/socket
unix  2      [ ACC ]     STREAM     LISTENING     15633    /var/run/dbus/system_bus_socket
unix  2      [ ACC ]     STREAM     LISTENING     16129    /tmp/ssh-AYHltf8zzAuv/agent.600
unix  2      [ ACC ]     STREAM     LISTENING     16960    /tmp/.X11-unix/X0
unix  2      [ ACC ]     STREAM     LISTENING     18495    /tmp/.ICE-unix/600
unix  2      [ ACC ]     STREAM     LISTENING     17542    @/tmp/dbus-0nAe1Vft
unix  2      [ ACC ]     STREAM     LISTENING     16959    @/tmp/.X11-unix/X0
unix  2      [ ACC ]     STREAM     LISTENING     14138    @/tmp/dbus-kLaALJuH
unix  2      [ ACC ]     STREAM     LISTENING     18494    @/tmp/.ICE-unix/600
unix  2      [ ACC ]     STREAM     LISTENING     14179    /run/user/1000/systemd/private
unix  2      [ ACC ]     STREAM     LISTENING     14184    /run/user/1000/gnupg/S.gpg-agent.browser
unix  2      [ ACC ]     STREAM     LISTENING     14187    /run/user/1000/bus
unix  2      [ ACC ]     STREAM     LISTENING     14189    /run/user/1000/gnupg/S.gpg-agent
unix  2      [ ACC ]     STREAM     LISTENING     14191    /run/user/1000/gnupg/S.gpg-agent.extra
unix  2      [ ACC ]     STREAM     LISTENING     14193    /run/user/1000/gnupg/S.gpg-agent.ssh
unix  2      [ ACC ]     STREAM     LISTENING     17539    /run/user/1000/keyring/control
unix  2      [ ACC ]     SEQPACKET  LISTENING     1427     /run/udev/control
unix  2      [ ACC ]     STREAM     LISTENING     14139    @/tmp/dbus-kLVeQt6a
unix  2      [ ACC ]     STREAM     LISTENING     17311    /run/user/1000/keyring/ssh
unix  2      [ ACC ]     STREAM     LISTENING     17313    /run/user/1000/keyring/pkcs11
unix  2      [ ACC ]     STREAM     LISTENING     9634     /run/systemd/private
unix  2      [ ACC ]     STREAM     LISTENING     9648     /run/systemd/journal/stdout
unix  2      [ ACC ]     STREAM     LISTENING     9653     /run/systemd/fsck.progress
unix  2      [ ACC ]     STREAM     LISTENING     17541    @/tmp/dbus-yMrL8O3f
unix  2      [ ACC ]     STREAM     LISTENING     18465    @/tmp/dbus-stZvWk5V9a
unix  2      [ ACC ]     STREAM     LISTENING     17404    /var/run/NetworkManager/private-dhcp

I get connection timed out, when trying to connect.

ssh b1012@192.168.0.104 -vvv
OpenSSH_7.6p1 Ubuntu-4ubuntu0.1, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /home/optoscale/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "192.168.0.104" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 192.168.0.104 [192.168.0.104] port 22.
debug1: connect to address 192.168.0.104 port 22: Connection timed out
ssh: connect to host 192.168.0.104 port 22: Connection timed out

Running

b1012@debian:~$ systemctl status ssh.service

Outputs:

● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enab
   Active: active (running) since Thu 2019-01-24 13:42:23 CET; 2h 0min ago
  Process: 3594 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCES
  Process: 3589 ExecReload=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
 Main PID: 2332 (sshd)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/ssh.service
           └─2332 /usr/sbin/sshd -D
10
  • Running nmap on localhost is probably not the most efficient method of finding open ports on your local system... using netstat -l should provide a more complete list of running listening services and ports, including Unix sockets. And netstat -lt will limit the list to TCP ports. – RubberStamp Jan 24 '19 at 13:57
  • Also, would be helpful if you provide output when attempting to SSH to your Debian server. ssh <user>@<host> -vvv – ryekayo Jan 24 '19 at 13:58
  • @RubberStamp, Thanks for the comments. I have updated the question with these details. – filiphl Jan 24 '19 at 14:11
  • Is 10.20.81.24 really the IP address of the target Debian server? (To check you can run ip a on that machine.) – roaima Jan 24 '19 at 14:22
  • 1
    From your Ubuntu box run telnet <IP> 22. If that times out on you, it may very well be your firewalls. A good test after that point would be to stop/disable the firewalls (temporarily). If you can connect with the firewalls disabled, you need to add a rule to listen on Port 22 with your incoming IP (<Ubuntu_IP>/32) – ryekayo Jan 24 '19 at 14:55
3

You have a NAT firewall between your two machines. You can see this because your Debian system's IP address is 192.168.0.24 but the Ubuntu system sees the associated inbound connection coming from 10.20.81.24.

Unless you control and manage this NAT firewall, it will be impossible for you to connect directly from your Ubuntu server to your Debian server. (Various work-arounds exist, including running autossh on your Debian system with a reverse tunnel, or OpenVPN initiated from Debian to Ubuntu. Either can allow connections to be made back the other way.)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.