Linux - Virtualization and CloudThis forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello, all. I have a Slackware virtual machine set up in VirtualBox with "NAT" networking, and I'm trying to set it up so that I can ssh into it from the host. I'm doing this because I want to learn more about ssh and networking in general, but there aren't any other machines in the house that run a *nix/BSD, so I have to use a VM.
I've tried following the guide in the VirtualBox user manual about port forwarding:
Quote:
p, li { white-space: pre-wrap; } You can set up a guest service which you wish to proxy using the command line tool VBoxManage. You will need to know which ports on the guest the service uses and to decide which ports to use on the host (often but not always you will want to use the same ports on the guest and on the host). You can use any ports on the host which are not already in use by a service. An example of how to set up incoming NAT connections to an ssh server on the guest requires the following three commands:
VBoxManage setextradata "Linux Guest" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP VBoxManage setextradata "Linux Guest" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22 VBoxManage setextradata "Linux Guest" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222
Here are the commands I put in to apply to my VM:
Code:
mrcode@linuxbox:~$ VBoxManage setextradata "SlackVM" "VBoxInterlan/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
VirtualBox Command Line Management Interface Version 3.0.8
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
mrcode@linuxbox:~$ VBoxManage setextradata "SlackVM" "VBoxInterlan/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
VirtualBox Command Line Management Interface Version 3.0.8
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
mrcode@linuxbox:~$ VBoxManage setextradata "SlackVM" "VBoxInterlan/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222
VirtualBox Command Line Management Interface Version 3.0.8
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
mrcode@linuxbox:~$
I'm guessing the lack of error messages means that it all worked. However, when I try the following:
Code:
ssh -p 2222 slackvm
it just gives me:
Code:
ssh: Could not resolve hostname slackvm: Name or service not known
I'm a real newb to this, so if there's something I'm doing very wrong (or not doing at all), please let me know. I got that the -p option is for port selection from the man page...is that right?
I've also tried ssh'ing to it by it's IP (10.0.2.15), but then it just sits there for a little bit (a couple minutes at least) and then tells me the connection timed out. Is there something I need to do in the VM in that time that it's just sitting there?
I've searched on Google about this issue, but none of the other forum threads and/or guides really apply to what I want to do...at least not exactly. I've searched LQ, too, but I can't find another thread that deals specifically with this issue.
I hope this thread is in the right place, but if it fits better in LInux - Networking, then please move it there.
Forgive me if this is obvious, but does your slackware install have an ssh server running ('ps -A' should show a line for the sshd daemon)?
Are you able to ping the machine? This will show you if your network is behaving the way you expect it to. Because it is on a private network, you will only be able to access it from the host.
You could try getting it going without port forwarding first, ie, just using the default ssh port (this will make it a lot simpler).
Last edited by neonsignal; 10-21-2009 at 06:22 PM.
Forgive me if this is obvious, but does your slackware install have an ssh server running ('ps -A' should show a line for the sshd daemon)?
According to both the boot-text startup parade and "ps -A", sshd is running. And trust me, when it comes to this kind of thing, nothing's obvious . I've never tried this before.
Quote:
Are you able to ping the machine? This will show you if your network is behaving the way you expect it to. Because it is on a private network, you will only be able to access it from the host.
I can't seem to get through to it at all. I did a "ping 10.0.2.15" but just sits there, not even giving any error messages. I'm pretty sure that's what the IP of the VM is, because doing an ifconfig in the VM gives that as the "inet addr" field.
Quote:
You could try getting it going without port forwarding first, ie, just using the default ssh port (this will make it a lot simpler).
I don't know how to set the port settings back to default...unless you just mean to exclude the -p option when I try to get in again, in which case it doesn't seem to be working.
I did a "ping 10.0.2.15" but just sits there, not even giving any error messages.
Which just means you are getting no response.
I wouldn't have thought you would need to set up the port forwarding, since you are not going to access the guest virtual machine from anywhere except the host (and the host is on the local NAT). It should be sufficient to just do the following in the host:
Code:
ssh 10.0.2.15
You will use IP addresses rather than hostnames (since you probably don't have any name resolution in place).
A few more questions:
1. Is the guest able to access other machines (eg, from the guest, can you ping 10.0.2.1, or any IP addresses on the real network)? (if not, then for some reason the virtual box network adapter is not working)
2. Are you using the same username on both the host machine and the guest virtual machine? (if not, you can do something like ssh user@10.0.2.15).
3. What version of VirtualBox are you using?
You could also try using host networking instead of NAT in the virtual box configuration of the guest (effectively this places the guest onto the real network, which can simplify things).
My understanding is that your setup is as follows: you have a host machine called 'linuxbox', a guest machine connected using a (virtual) NAT called 'slackvm' running sshd, and you are attempting to ssh from the host machine into the guest.
You could also try using host networking instead of NAT in the virtual box configuration of the guest (effectively this places the guest onto the real network, which can simplify things).
Thanks for the tip! I switched the networking to "Host-only Adapter" and it appears I can access the VM via ssh now. I can't access the Internet through the VM anymore, though (this is probably because it's no longer using the wlan0 interface of the host like it was when I was using NAT).
Also, I got this message when I did a "ssh 192.168.56.101" (the IP assigned to the VM after switching):
Code:
The authenticity of host '192.168.56.101 (192.168.56.101)' can't be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)?
Is this anything to be worried about? (I've censored the RSA key).
One last thing: while the VM was still on NAT, I could only ping outside websites and the host. I tried ssh'ing into the host, but it just gave me a "Connection refused" message. I'm guessing this just means that I could, in theory, go the other way around using NAT? I'm guessing all I'd need to do is do some configuring on the host to allow the VM to connect.
Thanks for the tip! I switched the networking to "Host-only Adapter" and it appears I can access the VM via ssh now. I can't access the Internet through the VM anymore, though (this is probably because it's no longer using the wlan0 interface of the host like it was when I was using NAT).
i just did exactly the same, thats why i know:
you need to add a second network adapter in the network-settings (one NAT for networking and another host-only for ssh-connection).
i hope this is correct for you too and it will work.
from guest to host it should be :
ssh 192.168.56.1
and from host to guest it should be:
ssh 192.168.56.101
per default, but you may check with ifconfig. ssh 10.0.2.15 doesnt work over here, i cant tell you why (or what 10.02.15 is good for)
about the RSA-keyring you dont need to be worried. Its the usual procedure the first time the connection is made. as far i understand :-) .
Are you sure you want to continue connecting (yes/no)?
Is this anything to be worried about? (I've censored the RSA key).
As j1alu says, it is quite normal. The security problem is that if someone was intercepting the communications, then ssh could be connecting to another machine (masquerading as the real one). So the warning (if you were being pedantic about security) is so that you can check for a key match.
Quote:
I can't access the Internet through the VM anymore, though (this is probably because it's no longer using the wlan0 interface of the host
I can't test this out here (I don't have a wireless interface), but the network settings on VirtualBox may allow you to select which host interface you wish to use.
Quote:
while the VM was still on NAT, I could only ping outside websites and the host. I tried ssh'ing into the host, but it just gave me a "Connection refused" message.
Connection refused could mean that sshd is not running, or that it has been secured to only respond to certain addresses. Changing to a NATed network won't change this.
When the guest was on the NAT, there are two ways for it to connect to the host, because the host has two IP addresses, one facing out to the home network (192.168.56.X), one facing in to the virtual NAT (might be 10.0.2.2).
I had another look at the NAT interface on VirtualBox, and it seems that you have to do port forwarding in order to communicate to the guest (even from the host). Part of the problem is that VirtualBox is not necessarily running as root, so it can't just automatically route the standard port addresses. I'm not sure why your VBoxManage forwarding didn't work (though I did notice that you had VBoxInterlan instead of VBoxInternal, perhaps a typo).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.