以root用户远程登陆ubuntu提示:
Please login as the user "ubuntu" rather than the user "root"
解决办法
一、编辑ssh登录方式:
1 2 3 4 5 6 7 8 9 10 11
#编辑SSH文件 sudo vim /etc/ssh/sshd_config
#密码认证改为 yes PasswordAuthentication yes
#root登陆许可改为 yes PermitRootLogin yes
#PAM认证改为 no UsePAM no
二、再编辑authorized_keys文件:
1 2 3 4 5
#打开authorized_keys sudo vim /root/.ssh/authorized_keys
#删除ssh-rsa前面的所有内容 如:no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command="echo 'Please login as the user \"ubuntu\" rather than the user \"root\".';echo;sleep 10;exit 142"
内容命令描述
1 2 3 4 5 6 7 8
#当此密钥用于身份验证时禁止TCP转发 no-port-forwarding #使用此密钥进行身份验证时,禁止身份验证代理转发 no-agent-forwarding #当此密钥用于认证时禁止X11转发 no-X11-forwarding #用户提供的命令(如果有)被忽略 command="echo "'Please login as the user \"ubuntu\" rather than the user \"root\".'