1

我是ansible的新手。尝试在 amazon linux 实例中配置它以了解有关 ansible 的基本知识。ansible 安装后,我使用命令 ssh-keygen 创建了一个 ssh 密钥对。生成后,我尝试运行命令“ 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).

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

4

1 回答 1

1
ssh-copy-id localhost

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

如果您需要设置 pubkey 身份验证而不允许密码身份验证,只需将公钥复制到本地(因为它是 localhost):

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
于 2017-04-12T07:30:20.093 回答