MacOS上的虚拟机软件用的Parallels Desktop。虚拟机也就偶尔开一下,设置的密码经常忘记,导致经常打开后要重置密码。不想记住麻烦的命令,于是写了一个重置虚拟机密码的脚本:
#!/bin/bash
# reset passowrd of parallels desktop VMs
#author tlanyan<[email protected]>
prlctl list -a
machines=`prlctl list -a|sed '1d'`
count=`echo "$machines"|wc -l`
((count--))
read -p "please select vm index[0-$count]:" index
if [ $index -gt $count ]; then
echo "invlid choice!"
exit
fi
((index++))
line=`echo "$machines" | sed -n ${index}p`
echo your choice: $line
id=`echo "$line" | tr '{}' ' ' | awk '{print $1}'`
read -p "please input username:" username
read -p "release input password:" password
prlctl set $id --userpasswd $username:$password