Last active
March 16, 2017 12:36
-
-
Save vasekch/9e1d8827e3099ef677f27334db5b114f to your computer and use it in GitHub Desktop.
ssh config to virtualbox with unknown ip - find out from guest properies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# can not use HostName because ip is dynamic | |
# target machine is vm in virtual box and has bridged interface to the network | |
# this is useful when you run vm that shall be accessible the same way as host | |
# machine is and you can not have statically assigned ip from dhcp | |
# edit: following comment is outdated | |
# prerequisity is to have `socat` and `arp-scan` commands available (installed) | |
# also need of providing password for sudo may be avoided by setting sudoers | |
# with proper NOPASSWD directive | |
Host zs | |
# HostName 10.4.1.2 | |
# ProxyCommand bash -c 'socat stdio tcp:$(sudo arp-scan --interface em1 -l | grep 08:00:23:78:ac:23 | cut -f 1):22' | |
# edit: more convenient way without sudo and nasty arp-scan | |
# ProxyCommand bash -c 'socat stdio tcp:$(arp -a | grep 08:00:23:78:ac:23 | cut -d " " -f 2 | tail -c +2 | head -c -2):22' | |
# edit: previous doesn't work every time - most convinient way is using vbox guest additions | |
ProxyCommand bash -c 'socat stdio tcp:$(VBoxManage guestproperty get <VBOX_NAME> "/VirtualBox/GuestInfo/Net/0/V4/IP" | cut -d " " -f 2):22' | |
User root | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please use
VBoxManage guestproperty get <VM_NAME|VM_UUID> "/VirtualBox/GuestInfo/Net/0/V4/IP"
if it works for you. (for vbox version < 5.1 you need to have installed guest additions extra)You can list all available properties by
VBoxManage guestproperty enumerate <VM_NAME|VM_UUID>
.Also using
arp -a
instead ofarp-scan
is more legit way to do it.arp-scan
may get detected by monitoring tools as malicious behaviour.