我想使用 ssh key 和密码通过 ssh 登录到我的 Centos 7 AWS 机器。
但是当我通过 ssh 进入我的机器时,我没有被提示输入密码就登录了。
我的情况:
- AMI:CentOS 7 (x86_64) - 带有更新 HVM
- 我禁用了 root 登录并创建了 user1 以使用 ssh 登录
- user1 ~/.ssh 拥有权限:0700
- user1 ~/.ssh/authorized_keys 拥有权限:0600
- user1属于wheel组
- 为 user1 设置了密码
- sshd_conf:
Match User user1
PasswordAuthentication yes
PubkeyAuthentication yes
最佳答案
如果您的 key 在 authorized_keys
中,则不需要密码。
如果您想使用密码来解锁您的 key ,这样如果有人窃取了您的 key ,他们将无法通过 ssh 访问您的机器,那么请使用 ssh-keygen
生成受密码保护的 key ,然后用那个。
然后您可以通过在 /etc/ssh/sshd_config
中设置 PasswordAuthentication no
来强制进行 ssh key 验证。
# Change to no to disable tunnelled clear text passwords
PasswordAuthentication no
这样,用户将被迫使用 key ,并使用密码解锁该 key 。
关于linux - centos 7 AWS(使用 ssh key 和密码登录),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46959886/