oracle cloud 服务器开启密钥+密码访问的坑点

内容目录

环境

ubuntu24.04

问题情况

明明PasswordAuthentication yes 然后

systemctl restart ssh

了还报错

Permission denied (publickey).
"Public Key" / "Password and Public Key" method required. (33)

解决

查看配置文件 发现还引用/etc/ssh/sshd_config.d/*.conf

root@ubuntu24-04:~# grep -v '^#' /etc/ssh/sshd_config | grep -v '^$'
Include /etc/ssh/sshd_config.d/*.conf
PermitRootLogin yes
AuthorizedKeysFile      .ssh/authorized_keys .ssh/authorized_keys2
PasswordAuthentication yes
KbdInteractiveAuthentication no
UsePAM yes
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem       sftp    /usr/lib/openssh/sftp-server

进去一看

root@ubuntu24-04:~# grep -v '^#' /etc/ssh/sshd_config.d/60-cloudimg-settings.conf | grep -v '^$'
PasswordAuthentication no

改为yes 重启可用密码登陆了

小知识点grep过滤注释以及空行

grep -v '^#' /path/to/filename | grep -v '^$'

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注