重置Parallels虚机密码

  太久没有用虚机了,root密码都忘了,网上找了一个脚本,很方便的修改任意用户密码(虚机要开机),跑起来会列举装的虚机,提示用户输入用户和新密码。

#!/bin/bash
# reset passowrd of parallels desktop VMs
#author qiquanji<qiquanji@hotmail.com>

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

 

posted @ 2022-10-26 12:04  badwood  阅读(189)  评论(0编辑  收藏  举报
Badwood's Blog