"Host key verification failed" 在 Gitlab_ci 尽管存在 ssh_key
"Host key verification failed" on Gitlab_ci although ssh_key is present
"Host key verification failed." on Gitlab_ci when 运行ning "ssh name@server"
这是我的 gitlab_ci 的一部分,它应该登录到我的服务器和来自 repo 的 运行 脚本:
script:
- which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
- eval $(ssh-agent -s)
- ssh-add <(echo -e "$SSH_PRIVATE_KEY")
- echo "debug"
- echo "$SSH_PRIVATE_KEY" # all is ok here, it'll be printed
- echo "debug"
# - here comes an error
- (cat ./script/script1.sh) | ssh -t -t $SSH_USERNAME@$SSH_HOST
错误:
Host key verification failed.
ERROR: Job failed: exit code 1
为什么会报错?变量已设置。
当我从本地计算机和 Gitlab 手动执行相同操作时,私钥确实有效。
除了 Git error: “Host Key Verification Failed” when connecting to remote repository,检查你的 .known_hosts 文件。
如果同一私钥在本地工作,那可能是因为在本地,您的 ~/.ssh/known_hosts
文件对您要连接的远程服务器进行 include the ssh_keyscan
。
确保你的 GitLab CI 工作也是如此。
今天又碰壁,解决了
我的解决方案是向 ssh 添加一个 -oStrictHostKeyChecking=no
选项。
我发现这个问题是由 ssh 向您询问以下问题引起的,这不应该出现在日志中。
The authenticity of host 'xxx' can't be established.
ESDSA key fingerprint is xxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)?
选项 -oStrictHostKeyChecking=no
将抑制这一点,因此您的 ssh 可能会正常工作。
希望对遇到同样问题的人有所帮助
"Host key verification failed." on Gitlab_ci when 运行ning "ssh name@server"
这是我的 gitlab_ci 的一部分,它应该登录到我的服务器和来自 repo 的 运行 脚本:
script:
- which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
- eval $(ssh-agent -s)
- ssh-add <(echo -e "$SSH_PRIVATE_KEY")
- echo "debug"
- echo "$SSH_PRIVATE_KEY" # all is ok here, it'll be printed
- echo "debug"
# - here comes an error
- (cat ./script/script1.sh) | ssh -t -t $SSH_USERNAME@$SSH_HOST
错误:
Host key verification failed.
ERROR: Job failed: exit code 1
为什么会报错?变量已设置。
当我从本地计算机和 Gitlab 手动执行相同操作时,私钥确实有效。
除了 Git error: “Host Key Verification Failed” when connecting to remote repository,检查你的 .known_hosts 文件。
如果同一私钥在本地工作,那可能是因为在本地,您的 ~/.ssh/known_hosts
文件对您要连接的远程服务器进行 include the ssh_keyscan
。
确保你的 GitLab CI 工作也是如此。
今天又碰壁,解决了
我的解决方案是向 ssh 添加一个 -oStrictHostKeyChecking=no
选项。
我发现这个问题是由 ssh 向您询问以下问题引起的,这不应该出现在日志中。
The authenticity of host 'xxx' can't be established.
ESDSA key fingerprint is xxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)?
选项 -oStrictHostKeyChecking=no
将抑制这一点,因此您的 ssh 可能会正常工作。
希望对遇到同样问题的人有所帮助