#!/bin/bash # # RDP Authentication # This is using VBoxAuthSimple # Ok to run multiple times for multiple users # if [ "$UID" -eq 0 ] then echo "This script should NOT be run as root." exit 1 fi # if [ $# -ne 1 ]; then echo "Usage for $0 : VM Name required as argument." exit 1 fi # # Virtual Machine Name VB_VM_NAME=$1 # # Check if VM is powered-off VM_POWERED_ON=`VBoxManage list runningvms|grep -c '^"'${VB_VM_NAME}'"'` if [ $VM_POWERED_ON -eq 1 ]; then echo "VM needs to be powered off or saved" exit 1 fi # echo -n "RDP User:" read VB_VM_VRDP_USER echo -n "RDP Pass:" read -s VB_VM_VRDP_PASS echo echo -n "Re-enter RDP Pass:" read -s VB_VM_VRDP_PASS1 echo if [ $VB_VM_VRDP_PASS != $VB_VM_VRDP_PASS1 ]; then echo "Passwords do not match" exit 1 fi # VBoxManage setproperty vrdeauthlibrary "VBoxAuthSimple" VBoxManage modifyvm ${VB_VM_NAME} \ --vrdeauthtype external VB_VM_VRDP_PASS_HASH=`VBoxManage internalcommands passwordhash \ "${VB_VM_VRDP_PASS}"|cut -d" " -f3` VBoxManage setextradata ${VB_VM_NAME} \ "VBoxAuthSimple/users/${VB_VM_VRDP_USER}" ${VB_VM_VRDP_PASS_HASH} # Display Auth data VBoxManage getextradata ${VB_VM_NAME} enumerate|grep VBoxAuthSimple # exit