ios系统:macOS Sonoma 14.5
MAC OS:
# 创建组
sudo dscl . create /Groups/optuser gid 6666
# 创建用户
sudo dscl . create /Users/optuser uid 8888
sudo dscl . create /Users/optuser gid 6666
sudo dscl . create /Users/optuser shell /bin/bash
# 修改用户的密码
sudo passwd optuser
# 创建用户的home目录
sudo mkdir /Users/optuser
# 用户的home目录宿主
sudo chown -R optuser:optuser /Users/optuser
# 声明用户的home目录
sudo dscl . create /Users/optuser home /Users/optuser
# 把用户添加到用户组内
sudo dscl . merge /Groups/admin users optuser
sudo bash -c 'echo "optuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers'
如下手动完成修改(命令执行报错,但命令没错)
sudo sed -i 's#PermitRootLogin yes#PermitRootLogin no#g' /etc/ssh/sshd_config
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config.d/*.conf
重启SSHd
sudo launchctl unload -w /System/Library/LaunchDaemons/ssh.plist && sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
解决方案:
修改/etc/ssh/sshd_config 中取消UsePAM注释,改为UsePAM yes