512-rdp-auth-del
#!/bin/bash
#
# Remove RDP Authentication
# The script removes:
#   One User's auth - ok to enter dummy value
#   Sets the VRDE Auth to null
# Ok to run multiple times to remove 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
#
CNT_AUTH_SIMPLE=`VBoxManage getextradata ${VB_VM_NAME} enumerate | \
  grep -c "VBoxAuthSimple/users/"`
if [ $CNT_AUTH_SIMPLE -gt 0 ]; then
  echo "List of VBoxAuthSimple users:"
  VBoxManage getextradata ${VB_VM_NAME} enumerate | \
    grep "VBoxAuthSimple/users/" | cut -d"," -f1
  echo
  echo -n "RDP User:"
  read VB_VM_VRDP_USER
  echo
#
  VB_VM_AUTH_VALUE=`VBoxManage getextradata ${VB_VM_NAME} \
    "VBoxAuthSimple/users/${VB_VM_VRDP_USER}" | \
      grep -c "No value set"`
  if [ $VB_VM_AUTH_VALUE -eq 1 ]; then
    echo "No auth for user: $VB_VM_VRDP_USER - Nothing to delete"
    echo
  fi
# Delete user password hash
  VBoxManage setextradata ${VB_VM_NAME} \
    "VBoxAuthSimple/users/${VB_VM_VRDP_USER}"
else
  echo "No VBoxAuthSimple users found to delete"
fi
# Remove authentication
echo "Setting VRDE Auth type to null"
VBoxManage modifyvm ${VB_VM_NAME} --vrdeauthtype null
#
if [ $CNT_AUTH_SIMPLE -gt 1 ]; then
  echo "Rerun to delete other users. However authtype is already set to null"
fi
exit

QR Code
QR Code scripts:512-rdp-auth-del (generated for current page)