Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-25-2017, 03:19 PM   #1
LQ Newbie
Registered: Jul 2017
Posts: 4

Rep: Reputation: Disabled
Question SSH access to my ubuntu server

Hello all of you out there,

I have installed virtualbox and I am running ubuntu 16.04-2 64 bit as a virtual machine.
I can ping the server with IP address
But now I want to log on to the server using SSH.
The openssh-server package is installed but when I try to log on I get the message: ssh: connect to host port 22: Connection refused
My wifi network is configured to use DHCP and my wifi adapter gets an IP address of 192.168.124.x
I tried to set a static IP address but when I configure it that way I don't have access to the internet.
I have googled and configured SSH to use port 2222 but this doesn't help.
I also made a rule for ufw to accept connections on port 22

Anybody any ideas?

Thanks in advance.
Old 07-25-2017, 03:52 PM   #2
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
How do you have the network adapter configured in virtualbox? Bridged, NAT, etc.

Where do you want to SSH into the VM from? The host, some other machine on your network, or outside your network?
Old 07-25-2017, 04:06 PM   #3
Registered: May 2017
Distribution: Centos 6,7 and Windows
Posts: 40

Rep: Reputation: Disabled
Lets take it from the top.
When you first created the VM, how was it congfigured? Was it NAT, bridged, Host only adapter? Are you able to ping anything from inside the VM? What does the ONBOOT (yes, no) say in /etc/sysconfig/network-scripts/ifcfg-enp0s3 or eth0?
Old 07-25-2017, 04:20 PM   #4
Registered: May 2016
Location: Belgrade, Serbia
Distribution: Debian
Posts: 229

Rep: Reputation: Disabled
Where are you logging from with ssh? From your host where that vm is installed? From LAN? From outside?
Old 07-25-2017, 09:07 PM   #5
Registered: Dec 2016
Distribution: arch
Posts: 668

Rep: Reputation: 190Reputation: 190
How did you go about configuring ssh exactly? Did you use gui interfaces or the command line? I believe UBuntu 16 is systemd. if so, you can check the server is running via
systemctl status sshd
you should get something like
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: disable
   Active: active (running) since Sun 2017-07-23 06:51:50 PDT; 2 days ago
 Main PID: 871 (sshd)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/ssh.service
           └─871 /usr/sbin/sshd -D
lines 1-7/7 (END)
note the bolded text.

Also check your configuration file
your-favorite-text-editor /etc/ssh/sshd_config
and make sure the "Port" reads 2222, as you said you have set it. Though if you're paranoid enough I'd recommend changing this to something else and not post the port number online, and also make sure your firewall rule allows the same port that you're changing it to. Then reload the service
systemctl restart sshd
Note that most of these commands require root privileges.

Last edited by TheEzekielProject; 07-25-2017 at 09:08 PM.
Old 07-25-2017, 09:20 PM   #6
LQ Guru
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
You have to use bridged networking in the VM.
Old 07-26-2017, 08:14 AM   #7
LQ Newbie
Registered: Jul 2017
Posts: 4

Original Poster
Rep: Reputation: Disabled
The current situation

Thank you all for your help.
The situation is as follows: I am on a wifi network of 192.168.124.x this is my only network.
I have configured the virtual machine's NIC as a bridged adapter which is attached to wl0
I have checked the Cable connected radio button.
From the virtual machine I can ping the host for example ping
From my linux Mint terminal I can ping (this is the ip address I gave ubuntu server)
Promiscuous mode is set to allow all
From giving the command systemctl status sshd I found that the server was listening on port strange enough.
So I edited /etc/ssh/sshd_config
There I set the ip address to
Now I can log on using SSH but the connection seems to be somewhat unstable.
Sometimes the link is broken.
But I think this is what I have to be satisfied with.

Again thank you all for your time
Old 07-26-2017, 01:08 PM   #8
LQ Veteran
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,662

Rep: Reputation: 2197Reputation: 2197Reputation: 2197Reputation: 2197Reputation: 2197Reputation: 2197Reputation: 2197Reputation: 2197Reputation: 2197Reputation: 2197Reputation: 2197
Originally Posted by janvitro View Post
From giving the command systemctl status sshd I found that the server was listening on port strange enough.
Just FYI - that's not the port, that means the server is listening on all IP addresses. The port follows the colon.

Glad you figured out the problem, tho.
Old 07-27-2017, 03:46 AM   #9
LQ Newbie
Registered: Jul 2017
Posts: 4

Original Poster
Rep: Reputation: Disabled
Trouble in virtualization land

I prefer to use VirtualBox instead of VMware because VirtulBox is open source.
I configured the whole thing and I can log on to my server but much to often I get something like:
cannot connect to port 22 connection refused (I don't know the exact output)
What I did is install VMware player again, on one virtual machine I run pfSense profiding NAT and many other features.
I then assigned an extra IP address to my wifi adapter.
I now have a virtual network isolated from th rest which I can access from my Mint terminal.
VirtualBox can a thing or two from the ease of which everything is installed and it's stabilaty.
But maybe the problem isn't VirtualBox but me . . .
But for now I'm happy with the current configuration despite of the fact that VMware isn't open source.
Thank you all for your time and effort.

Best regards,



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ubuntu 12.4 LTS ssh access kohshan99 Linux - Newbie 8 09-19-2016 02:14 AM
Help with Ubuntu server remote ssh and local network ssh issues using putty. scottpops Linux - Server 8 05-17-2012 06:07 PM
Firestarter kills OUTGOING SSH Ubuntu 10.04- rejects SYN/ACK from SSH server edsmithers Linux - Networking 3 09-29-2010 03:53 PM
Using DSL and ssh / ssh-server to access the Windoze desktop GUI On2ndThought Linux - Server 4 11-16-2008 03:17 PM
Unable to access my ssh server and ftp server from the Internet, but smtp works foxone Linux - Networking 1 05-28-2004 06:17 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:47 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration