问题原文
原帖链接 · CodeQuestor · CC BY-SA 4.0
I have AWS codebuild setup where want to access the EC2 ubuntu instance both are in same VPC and private subnet. Want to execute the command from codebuild to instance using SSH but getting below error, while trying to execute the command on the remote instance:
$ ssh -o 'PubkeyAuthentication no' [email omitted] uname
Host key verification failed.
I also tried to create the .pem file and pasted the public key to the new pem file, changed its permission and used that. But no success.
$ssh -i "remote-instance.pem" [email omitted] uname
Host key verification failed.
Is it possible to achieve the same with some options?
已采纳解答
原帖链接 · MLu · CC BY-SA 4.0
As you know the first time you ssh to a remote host it asks you whether you'd like to store the remote host key to ~/.ssh/known_hosts. Every time you access the remote host afterwards ssh verifies received host key against ~/.ssh/known_hosts.
However when ssh runs in CodeBuild or some other non-interactive setup it can't ask whether to accept the remote key (because there's no one to ask in a non-interactive session) and to be on the safe side it fails with Host key verification failed
You've got two options how to fix it:
More secure is to provide the Ubuntu server's host key to your CodeBuild and store it to a
known_hostsfile wheresshcan verify it. Make sure it's in the right path with the correct ownership and permissions.Less secure is to disable the check:
ssh -o StrictHostKeyChecking=no {your-ubuntu-server}
Hope that helps :)
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
