0

From Ubuntu 18 lts I'm trying to establish ssh connection with my Kali Linux VirtualBox on the same computer. I've already installed openssh-client and openssh-server on both systems and I'm connected to Internet via ethernet cable. So, I have 'enp2s0' interface (on both systems) which is found in 'ifconfig' and I changed my network ipv4 addresses to static with the same IP addresses I found in 'ifconfig':

In Ubuntu:

IP: 192.168.1.8

In Kali:

IP: 192.168.1.5

Netmask: 255.255.255.0 and Default Gateway: 192.168.1.255 are same on both systems. In VBox settings for Kali I configured network to Bridge connection. I checked ping between these systems and it is ok (64bytes..blahblah). I turned off firewall on both systems:

sudo ufw disable

so it's inactive. The problem is that, I can connect from Kali shell to Ubuntu, but not vice versa where I'm getting the following message:

ssh: connect to host 192.168.1.5 port 22: Connection refused

I also tried with: sudo ufw allow 22 on both and nothing.

sudo ufw ssh enable didn't help.

Answers on comments:

netstat -an | grep 22 gives me:

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp       69      0 192.168.1.8:53436       13.32.28.22:443         ESTABLISHED
tcp6       0      0 :::22                   :::*                    LISTEN     
unix  2      [ ]         DGRAM                    3766327  /var/lib/samba/private/msg.sock/922
unix  2      [ ]         DGRAM                    3805225  /run/wpa_supplicant/wlp3s0mon
unix  3      [ ]         STREAM     CONNECTED     2717922  /run/user/1000/bus
unix  3      [ ]         STREAM     CONNECTED     2869722  
unix  3      [ ]         STREAM     CONNECTED     3802265  
unix  3      [ ]         STREAM     CONNECTED     3802266  
unix  3      [ ]         STREAM     CONNECTED     2335221  
unix  3      [ ]         STREAM     CONNECTED     2341225  /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     1822     /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     3773622  
unix  3      [ ]         STREAM     CONNECTED     27122    /run/user/121/bus
unix  3      [ ]         STREAM     CONNECTED     3802298  
unix  3      [ ]         STREAM     CONNECTED     3802297  
unix  3      [ ]         STREAM     CONNECTED     2468922  
unix  2      [ ]         DGRAM                    2339422  
unix  3      [ ]         STREAM     CONNECTED     2332622  
unix  3      [ ]         STREAM     CONNECTED     3853822  
unix  3      [ ]         STREAM     CONNECTED     29227    
unix  3      [ ]         STREAM     CONNECTED     29228    
unix  3      [ ]         STREAM     CONNECTED     2329522  
unix  3      [ ]         STREAM     CONNECTED     3766622  
unix  3      [ ]         STREAM     CONNECTED     2329922  
unix  3      [ ]         STREAM     CONNECTED     28122    /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     2888122  
  • do you have any firewall rules setup that would refuse an ssh connection? also netstat -an | grep 22 – j-money Sep 6 '18 at 21:15
  • 2
    192.168.1.255, which is the last address of the subnet, is, by definition, the broadcast address and can't be the default gateway. Something is wrong in your configuration. – Kev Inski Sep 6 '18 at 21:32
  • If that is true, how is it possible I can connect from Kali to Ubuntu, but not vice versa? – mk1024 Sep 6 '18 at 22:21
  • Try with ssh -vvv <host-or-ip> to get more verbose report. I'm not familiar with Kali but UFW is front-end for IPTables, so try to remove all iptablesrules, maybe there still something. – pa4080 Sep 7 '18 at 11:01
0

It can be that there is other server with same IP in your network... and that is why you get connection refused. Other case can be the way you have routing setted at your host. Please consult this documentation. So... you can have NAT for your virtual box, and "by accident" that is same address range as for host's NAT. Change connection settings to bridged, and retry.

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.