简介
parallels 14.1.3
虚拟机macos 10.15.6
前提是对用户写了ssh公钥,只是忘了密码无法登陆
重置root密码
网上找的
#!/bin/bash
# reset passowrd of parallels desktop VMs
#author tlanyan<tlanyan@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
创建一个管理员用户
ssh上去 su到root
dscl . -create /Users/papa
dscl . -create /Users/papa UserShell /bin/bash
dscl . -create /Users/papa RealName "papa"
#保证UniqueID唯一
dscl . -create /Users/papa UniqueID "555"
dscl . -create /Users/papa PrimaryGroupID 80
dscl . -create /Users/papa NFSHomeDirectory /Users/papa
#修改密码:
dscl . -passwd /Users/papa password
#加入admin用户组
dscl . -append /Groups/admin GroupMembership papa
通过gui登陆进去
在系统偏好设置中的用户与用户组中修改愿管理员密码
删除管理员用户
dscl . -delete /Groups/admin GroupMembership papa
在虚拟机页面备注密码
避免下次遗忘