# 1. 以 root 用户登录
ssh root@xxxxxxxx
# 2. 将 opc 添加到 wheel 组
usermod -aG wheel opc
# 3. 创建免密 sudo 配置
echo "opc ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/opc
chmod 440 /etc/sudoers.d/opc
# 4. 验证
su - opc
sudo whoami # 应该输出 root,不需要密码
# 1. 以 root 用户登录
ssh root@xxxxxxxx
# 2. 将 opc 添加到 wheel 组
usermod -aG wheel opc
# 3. 创建免密 sudo 配置
echo "opc ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/opc
chmod 440 /etc/sudoers.d/opc
# 4. 验证
su - opc
sudo whoami # 应该输出 root,不需要密码