Active7 months ago
To connect to your Linux (Ubuntu) Machine Step 1 - Start PuTTY. From the Start menu, choose All Programs PuTTY PuTTY. Step 2 - In the Category pane, choose Session. Step 4 - Click Open in the PuTTY dialog box. The connection should open in a new window. Connect to your Linux instances from Windows using PuTTY, a free SSH client for Windows. Its status checks. You can view this information in the Status Checks column on the Instances page. For an Ubuntu AMI, the user name is ubuntu.
I have set up a VM of Ubuntu server, have installed OpenSSH, and am now trying to connect to it using Putty. Within Putty, under 'Host name', I put 'Ubuntu', given this is what I thought it was called when I set up the VM. However, I just get the error: 'Connection Timed Out'.
I also tried putting '127.0.0.1' into the host name within Putty and just get 'Connection Refused'. Note that I have done the port forwarding for SSH and HTTP within Oracle VM, so I am at a loss as to how to get it running.
wickywillswickywills90922 gold badges88 silver badges1414 bronze badges
6 Answers
VirtualBox will create a private network (10.0.2.x) which will be connected to your host network using NAT. (Unless configured otherwise.)
This means that you cannot directly access any host of the private network from the host network. To do so, you need some port forwarding. In the network preferences of your VM you can, for example, configure VirtualBox to open port 22 on 127.0.1.1 (a loopback address of your host) and forward any traffic to port 22 of 10.0.2.1 (the internal address of your VM)
This way, you can point putty to Port 22 of 127.0.1.1 and VirtualBox will redirect this connection to your VM where its ssh daemon will answer it, allowing you to log in.
Jeff Schaller♦50.1k1111 gold badges7474 silver badges166166 bronze badges
michasmichas16.4k33 gold badges4040 silver badges7474 bronze badges
I wanted to use putty to connect to my ubuntu on virtual box (comfort reasons, the VB is just weird. I can't work unless it is on a proper terminal).Anyway,
- Make sure ssh client is installed on your Linux. If not, install it
sudo apt install ssh
. - Power off the OS.
- Now on your VB go to
Settings
->
Network
->
onAdapter 1
chooseHost-only adapter
->clickOK
. - Now start your OS. Run
ifconfig
; now the inet address is your IP. - Use this and run it on your putty. Login with your credentials.
The only disadvantage of using host-only adapter is that your guest OS won't have access to the wider network (eg the Internet).
If you also need your VM to have internet access, leave Adapter 1 as NAT and enable Adapter 2, configured as a Host-Only adapter. This will allow your VM to connect to the internet using NAT as well as make a local connection to your Host using Host-Only.
Priya_user1907390Priya_user1907390
First you need to decide if your VM connected to your host machine via a bridge connection or via a NAT, but ether way you'll need to put the VM IP address in putty to be able to connect to ip, in the VM terminal run this command to show you the machine IP address(and no 127.0.0.1 is not the machine IP address)
in this case my IP address will by 10.0.2.15,
First try to make sure you can communicate on a basic level with VM, open a terminal window on your host, and try to ping the VM
If you get ant result, then make sure you have a ssh service running on the VM, in the terminal on your VM type as root,
This tell as we have a service/process with PID(2361) called sshd (OpenSSH daemon) listening to port 22.
You can test if the service work correctly by trying to ssh to it from the VM it self,
Next you neet to make sure that you are not blocking port 22 in your firewall/iptables, I can not believe so, but check it out anyway. In the VM type this command to show you the iptables,
in the output you should have line like this one:
RabinRabin2,72811 gold badge1111 silver badges2121 bronze badges
My resolution was similar to Roman T's however I needed to add a few extra steps. In my case I had Ubuntu Server 14 VM running on a Windows 8 Desktop in Windows 2008 domain. If I tried NAT or Bridge I could access the Internet but couldn't connect via SSH.
If I tried Host Only Adapter then that would allow me to SSH to machine but couldn't access the Internet.
I tried Port forwarding as well and no joy. Opened up Wireshark and it just wasn't finding VM.
So my solution was to add a second network adapter.
With VM powered down
- Click Settings > Network Click Adapter 1 and choose Bridged Adapter
- Click Adapter 2 and choose Host Only Adapter
- Click File > Preferences > Networks Under NAT Networks if you don't see a NAT Network click on + icon to add NAT Network.
- Click Host-Only Networks if you don't see a host only network click + icon to add one
Start up VM
- In order to see network adapter you need to type
- You may see the network adapter is added with a mac address but not an IP?
- If so then you need to edit /etc/network/interfaces in order to configure DHCP. Example below using VI/VIM but you can use editor of your choice
- add the lines
- save and exit file.
- Then try restarting network service using below command
- Or if that fails then restart VM.
- Once restarted type below to see if you eth1 has been allocated an IP address
- if so then see if you can SSH on to the VM
mrjamesmyersmrjamesmyers
The following instructions worked with Ubuntu 14.04 and Oracle VirtualBox 4.3.30.
Do this in VirtualBox:
- Right-click your virtual machine, select 'Settings', and then select 'Network'.
- Next to 'Attached to', select 'Host-only Adapter'. As a side note, 'Bridged Adapter' will also work, check the VirtualBox documentation for more details about each option.
Do this inside your Virtual Machine:
- Find your network IP address by opening a terminal and typing
ifconfig
. Observe the IP address displayed next to eth0, under 'inet addr'. You can also see your IP address if you click the Network icon in the upper-right corner of your desktop, and then select 'Connection Information'. - Install openssh-server by typing the following at the terminal:
- Just in case, restart the virtual machine.
Now you can connect from PuTTY using the IP address from step 1 above and port 22.
Roman TRoman T
For Ubuntu 18.04 and VirtualBox 5.2:
- Create a Host Network Interfacei. On Virtualbox, click
File
/Host Network Manager
.ii. If you don't already have a Host Network adapter (defaultvboxnet0
), clickCreate
. - Enable Host-only Adapter settings for VMi. On Virtualbox, right click on your VM and select
Settings
.ii. ClickNetwork
and selectAdapter 2
.iii. ClickEnable Network Adapter
.iv. UnderAttached to:
selectHost-only Adapter
. The name of the adapter you created in step 1 should appear (defaultvboxnet0
). - Configure network settings in VMi. Start your VM and check which interface was added:
ip a
. Look for the interface that doesn't have aninet
address. On mine, it wasenp0s8
.ii. Edit/etc/netplan/01-netcfg.yaml
. e.g.sudo vi /etc/netplan/01-netcfg.yaml
.iii. Under the settings for the original adapter, add configuration details:This assigns a static ip address for your VM for SSH convenience. If you wantdhcp
to handle the addressing instead, leave out the address and gateway config and setdhcp4
toyes
.iv. Reload the configuration file:sudo netplan apply
. - SSH into your VMi. If you have not installed
ssh
in the VM:sudo apt install ssh
.ii. From your host machine, SSH into the VM:ssh <username>@192.168.56.2
.
ooknosiooknosi
protected by Community♦May 16 '16 at 8:27
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Would you like to answer one of these unanswered questions instead?
Not the answer you're looking for? Browse other questions tagged ubuntuvirtualboxputty or ask your own question.
Finally decided to use Ubuntu for your Desktop OS? That’s great. Oh, you also have an Ubuntu (cloud) Server? Even better.
You may be using some of our recommended Linux distros for gaming. This tutorial will work on just about any Debian-based distro, including, but not limited to:
- Ubuntu 17.04
- Ubuntu 16.10
- Ubuntu 16.04
- Ubuntu 14.04
- Any flavor of Ubuntu, including Ubuntu MATE, Ubuntu Budgie, Ubuntu GNOME, Kubuntu, Lubuntu, Xubuntu…
- Debian 6, 7, 8 or any other Debian release.
Now, you can directly access your Ubuntu server via the desktop version of Ubuntu, straight from your Terminal. No need for PuTTy or other 3-rd party apps to access your server.
Note that you may already have SSH installed on your Ubuntu, so just try logging into your server or run this command to check if SSH is currently running:
Ok, so onto our SSH installation instructions. You can also install SSH via a GUI, but where’s the fun in that? You already started using a server anyway. So here are the instructions on how to enable SSH via terminal:
Open up Terminal
Either open it via your menu or just press
Ctrl + Alt + T
Install OpenSSH
From the official website:
OpenSSH is the premier connectivity tool for remote login with the SSH protocol. It encrypts all traffic to eliminate eavesdropping, connection hijacking, and other attacks. In addition, OpenSSH provides a large suite of secure tunneling capabilities, several authentication methods, and sophisticated configuration options.
In other words, you need to install OpenSSH so you can log into your server.
Install it by running the following command in your terminal:
Install it by running the following command in your terminal:
After the installation is done, you’ll have SSH enabled on your Ubuntu desktop.
Configure SSH
Now that you’ve installed SSH, you can configure it. Like changing the default port (recommended for security reasons), disabling “root” user login etc.
For now, we’ll just update our default SSH port (which is 22). First, open up the ssh configuration file by running the following command:
If you don’t have nano installed (it’s a text editor), run this command:
Once you open the file, find and change the following line from:
to
Use a different port number, whichever one you want to.
Once you are done, save and close the file with
Ctrl + W
, then Y
and hit Enter/Return
Before restarting SSH you need to configure your firewall to allow the port you provided before. If you’re using UFW, just run:
You need to check with your internet provider and your modem/router(s) if you need to allow the new port.
Now, restart SSH for the changes to take effect. Run the following command:
And that’s it. You are done.
Now you can use SSH to log into your server. Just open up Terminal and run:
To log into your server via SSH, right from your Ubuntu desktop terminal. Of course, change ‘username’, ‘ip’ and the port number you’re using on your Ubuntu server
For more information, read this: