gpt4 book ai didi

linux - Ansible amazon linux 权限被拒绝(公钥)

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:40:27 25 4
gpt4 key购买 nike

我是ansible的新手。尝试在 amazon linux 实例中配置它以了解有关 ansible 的基本知识。安装ansible后,我使用命令ssh-keygen创建了一个ssh key 对。生成后,我尝试运行命令“ssh-copy-id localhost”,但它以以下错误结束,

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
Permission denied (publickey).

有人可以指导我解决这个问题。

最佳答案

ssh-copy-id localhost

如果您没有在本地主机上的 ssh 服务器中启用密码身份验证,将无法工作。

如果你需要设置公钥认证而不允许密码认证,只需将公钥复制到本地(因为它是本地主机):

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh/
chmod 600 ~/.ssh/authorized_keys
# make sure the SELinux labels are correct:
type restorecon && restorecon -F .ssh .ssh/authorized_keys

关于linux - Ansible amazon linux 权限被拒绝(公钥),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43351769/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com