1

I am having difficulty connecting remotely to the ubuntu server from the mac terminal.

So far I have run:

sudo apt-get install openssh-server

when I try to connect via the ip address I get an error:

$ ssh root@*ip address*
ssh: connect to host *ip address* port 22: Connection refused. 

How do I go about resolving this? Thanks in advance for your help

Note: I am not actually typing ip address. I'm just using this in place of my actual server ip address

muru
  • 197,895
  • 55
  • 485
  • 740
  • Are you sure the ssh daemon is running on the ubuntu server? What is the output of this command? sudo netstat -pant | grep ssh – Ed Manet Sep 04 '14 at 18:21
  • tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 9288/sshd
    tcp6 0 0 :::22 :::* LISTEN 9288/sshd
    – John Smith Sep 04 '14 at 18:25
  • Looks like the server is listening; might be a firewall issue then. – Ed Manet Sep 04 '14 at 18:33
  • Thanks for the feedback. Any insight on how I could go about resolving this? – John Smith Sep 04 '14 at 18:35
  • 1
    Are you authenticating with keys? I believe that the default sshd_config for Trusty sets PermitRootLogin without-password (meaning you won't be able to login as root using password-based authentication - that's assuming you have even enabled the root account of course). – steeldriver Sep 04 '14 at 18:57
  • Thanks for the response. I enabled the root account via:http://askubuntu.com/questions/44418/how-to-enable-root-login. I am new to Ubuntu, so any further help would be appreciated. I am getting this error: WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!... – John Smith Sep 04 '14 at 22:14
  • Just enabling the root user is not enough. As steeldriver has said, you net to enable it in the SSH configuration as well: http://askubuntu.com/questions/511833/cant-ssh-in-as-root/511836#511836. That said, a connection refused error is not an effect of that. Can you ping the Ubuntu server from the osx system? – muru Sep 04 '14 at 23:08
  • Yes, I can ping the Ubuntu server. – John Smith Sep 04 '14 at 23:12
  • Also, I have already done: http://askubuntu.com/questions/511833/cant-ssh-in-as-root/511836#5118 The error: " WARNING: REMOTE HOST..." is the error I am getting even after enabling root account. – John Smith Sep 04 '14 at 23:22

1 Answers1

0

First try to ssh into the server with another user besides "root". Root remote connection is disabled by default. Or you can allow remote access with root. You will need to edit /etc/ssh/sshd_config, and comment out the following line:

PermitRootLogin without-password 

Just below it, add the following line:

PermitRootLogin yes

Then restart SSH:

service ssh restart

Another suggestion would be to ensure that the firewall was turned off on the VM before proceeding with the network adapter changes. Some O/S versions default with the firewall turned on which may block incoming SSH connection attempts. After turning off iptables or ufw depending on your O/S version or whichever service you are using. IF this doesn't resolve the issue, then try each network adapter setting within VirtualBox.

sudo ufw disable

or

sudo service iptables stop
muru
  • 197,895
  • 55
  • 485
  • 740
ddlingo
  • 130