mac ssh 连接virtualbox 里的debian 系统

If you worked only with a provided harddisk-file, this implies for me that you created the VM yourself. The default network-setting for new VMs is "NAT" so you have to create a NAT-Rule, routing the host's port 22 to the VM's port 22.

I don't know about MacOS, but under Linux, you'd have to use a port > 1024. I usually use ports starting with 10000 and the respective service-port. In your case, I'd make a port-mapping of 10022 -> 22. For the entry in the "host"-column I use and for the guest-side as addresses.

You get to the menu via "Right-click on VM" in VirtualBox Manager -> "Change" -> "Network"-tab -> "Port-Forwarding" 7 4

Now you can connect your VM:

ssh root@ -p 10022

SSH between Mac OS X host and Virtual Box guest

On Mac OS (host):

Shutdown your VM and do:

VirtualBox > Settings > Network > Add (you will get vboxnet0)

On a terminal ifconfig will show you new interface vboxnet0

VM's Settings > System > check "Enable I/O APIC." VM's Settings > Network > Adapter 2 > host-only vboxnet0

On Ubuntu (guest):

Install OpenSSH Server

Edit /etc/network/interfaces file to append the following lines:

auto eth1
iface eth1 inet static

Run sudo ifup eth1 from the Ubuntu command line. SSH server should be up and running. Switch to your host terminal and enter ssh


Relative Articles