How to enable ssh access to a VirtualBox guest

Enable ssh access to a virtualbox guest instance using VBoxManage. The guest is the guest machine name and should be quoted if the name contains spaces.

$ VBoxManage setextradata 'guest' "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" 2222
$ VBoxManage setextradata 'guest' "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" 22
$ VBoxManage setextradata 'guest' "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" TCP

I never remember the steps to do this hence a simple script will take care of that in the future.

#!/bin/sh
guest=$1
if [[ $1 == "" ]]
then
    echo "Usage: `basename $0` "
exit 1
fi
VBoxManage setextradata $1 "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" 2222
VBoxManage setextradata $1 "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" 22
VBoxManage setextradata $1 "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" TCP

 

Tags: 

Add new comment

Plain text

  • No HTML tags allowed.
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.