You might wish to access that Debian guest from another box on your host's LAN. Here's how to do so with SSH. (If you're on Windows, you can do this IMO most enjoyably from Git Bash or Cygwin, although SSHing more directly from Windows is also possible.)
These instructions should work just as well with Debian's jessie or wheezy releases (in all likelihood). One caveat: Debian normally disallows SSH access as root. Instead, log in as a regular user and do 'sudo' (or 'su') if you wish to be root.
GUEST
In your guest Debian operating system, install the software to accept your inbound SSH connection:
sudo apt-get install openssh-serverHOST
I. For the desired VM, adjust its VirtualBox settings:
- Choose network type NAT.
- Forward some inbound port on the host to inbound port 22 on the guest.
- To provide an additional layer of security, pick a number between 1024 and 49151 (inclusive and random) to be the inbound local port ('host port') on your physical VirtualBox host.
- In VirtualBox Manager, select your desired VM (it can be running).
- In the VirtualBox Manager menu, click Machine–Settings–Network.
- Ensure the 'Adapter 1' tab is selected.
- Ensure 'Enable Network Adapter' is checked.
- You'll see the words 'Attached to'. There, select 'NAT'.
- Ensure that the blue, drop-down arrow by the word 'Advanced' has dropped down to show you the advanced settings.
- Click the 'Port Forwarding' button.
- Click the green icon, bearing a plus sign, whose tooltip is 'Adds new port forwarding rule'.
- Find and select the newly-created row.
- In the 'Name' column, type 'guestssh'.
- Ensure 'Protocol' is 'TCP'.
- In the 'Host Port' column, type your inbound local port.
- In the 'Guest Port' column, type '22'.
- Name it 'VirtualBoxSSHInPort' followed by the port number.
- Under 'Edge traversal', ensure 'Block edge traversal' is selected.
- For the path to the receiving program, use the path to the VirtualBox executable (on your host system).
- In your VirtualBox host's system tray, click the icon of the active router.
- Make sure the drop-down arrow by the words 'Wireless Network Connection' is selected, so you see a list of routers.
- Find the name of your active router in the list.
- Right-click that name.
- Click on 'Status'.
- Click the 'Details' button.
- In the 'Property' column, find the words 'IPv4 Address'.
- Read across to the 'Value' column.
- Note its four, dot-separated numbers. That's the IP address of your VirtualBox host, in the LAN provided by its active router. And for your SSH connection command it will be your target IP address.
IV. Now you can test the availability of your inbound SSH connection.
By default, to log in, SSH detects your local username and tries to use it.
Typical Windows usernames begin with a capital letter, yet typical GNU/Linux usernames begin with a lower-case letter. Therefore SSH's default username likely will fail. So instead (from Windows), the SSH command to access your VirtualBox VM is:
$ ssh {lowercase username}@{target IP address} -p {host port}Since my name (and Windows username) is Mark, I enter:
$ ssh mark@{target IP address} -p {host port}Alternatively, instead of logging in, you can run a single command (per these tutorials) and retrieve its output to your local, non-SSH computer—e.g.:
$ ssh mark@{target IP address} -p {host port} cat some-file > hereOr, you can use SCP.
Copyright (c) 2015 Mark D. Blackwell.
No comments:
Post a Comment
Thanks for commenting on my post!