1

私は実行しています:

# copy public key to other hosts
for host in ec2-master.eu-west-1.compute.amazonaws.com \
ec2xxx.compute.amazonaws.com \
ec2xxx.compute.amazonaws.com; \
do ssh-copy-id -i ~/.ssh/id_rsa.pub $host; \
done

そこで、ec2-master.eu-west-1.compute.amazonaws.com で生成したキーを他のサーバーにコピーしようとしました。しかし、私はまだ得る

/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/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,gssapi-keyex,gssapi-with-mic).
The authenticity of host 'ec2xxx.eu-west-1.compute.amazonaws.com (10.0.xx.xx)' can't be established.
ECDSA key fingerprint is 3a:63xx:a6:19:xx:23:d1:xx:06:22:xx:a0:b9:8c:xx:cf.
Are you sure you want to continue connecting (yes/no)? 

だから私は許可が拒否されました。しかし、理由はわかりません。私は何を間違っていますか?

4

2 に答える 2

0

私はこのスクリプトを使用していますが、うまくいきます: Сan you try this

for host in ${hosts[*]}
do
echo $host
ssh-keyscan $host | tee -a ~/.ssh/known_hosts
sshpass -p 'mypass' ssh-copy-id myuser@$host
done
于 2016-01-26T14:46:00.340 に答える
0

ssh-copy-idコマンドを次のように変更してみてください。

ssh-copy-id -i ~/.ssh/id_rsa.pub ec2-user@$host

(Amazon Linux を使用していると仮定します -- ubuntuUbuntu を使用している場合はユーザーとして使用します)

アップデート:

問題は、既存のキーを使用したログインのみを受け入れるホストに新しいキーをコピーしようとしていることが原因である可能性があると思います(パスワードは許可されていません)。

これを で動作させることはできませんでしssh-copy-idたが、標準の ssh コマンドで実行できます。

cat ~/.ssh/id_rsa.pub | ssh -i AWS_key.pem centos@$host "cat - >> ~/.ssh/authorized_keys"

AWS_key.pemインスタンスを起動したときに AWS がインスタンスにアタッチしたキー ペアのプライベート部分はどこにありますか。

于 2016-01-26T09:43:20.487 に答える