ssh - 检查 ssh 连接不工作,但允许 ssh 连接

标签 ssh ssh-keys openssh inspec

我正在尝试在部署厨师食谱之前运行我所有的检查测试。我想知道我的实例的初始状态是什么。

我测试了 ssh 连接:

ssh -i $HOME/key.pem centos@server_ip_address

并且连接是允许的,但是当我尝试再次运行检查测试时,服务器:
inspec exec ntp/test/integration/ntp.rb -t ssh://centos@server_ip_address -i /home/centos/key.pem

我收到了这个错误:
I, [2017-01-17T14:10:32.835995 #2416]  INFO -- : [SSH] connection failed, retrying in 1 seconds (#<Net::SSH::AuthenticationFailed: Authentication failed for user centos@server_ip_address>)
I, [2017-01-17T14:10:34.619150 #2416]  INFO -- : [SSH] connection failed, retrying in 1 seconds (#<Net::SSH::AuthenticationFailed: Authentication failed for user centos@server_ip_address>)
I, [2017-01-17T14:10:36.403860 #2416]  INFO -- : [SSH] connection failed, retrying in 1 seconds (#<Net::SSH::AuthenticationFailed: Authentication failed for user centos@server_ip_address>)
I, [2017-01-17T14:10:38.188401 #2416]  INFO -- : [SSH] connection failed, retrying in 1 seconds (#<Net::SSH::AuthenticationFailed: Authentication failed for user centos@server_ip_address>)
W, [2017-01-17T14:10:39.971832 #2416]  WARN -- : [SSH] connection failed, terminating (#<Net::SSH::AuthenticationFailed: Authentication failed for user centos@server_ip_address>)
Transport error, can't connect to 'ssh' backend: SSH session could not be established

我不知道错误在哪里。有什么建议吗?

检查信息
chef gem list | grep inspec

inspec (1.9.0, 1.7.2)

最佳答案

好吧,我花了整个上午和下午的部分时间搜索,我找到了解决方案 here

我执行:

eval "$(ssh-agent)"

然后将我的 key 添加到代理:
ssh-add key.pem

所以现在我可以在不执行 key 的情况下运行 inspec 测试:
inspec exec cookbooks/ntp/test/integration/default/ -t ssh://centos@server_ip_address

好的,这是部分解决方案,因为我仍在寻找使用 -i并使用 key 作为参数。问题仍然存在。

关于ssh - 检查 ssh 连接不工作,但允许 ssh 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41699453/

相关文章:

perl - 在对变量执行 openssh 时无法捕获 stderr-perl

macos - 通过第三台机器的 SVN-SSH 隧道?

rsync - 你如何将构建文件从 Gitlab CI 同步到另一台服务器

git - 我没有 ~/.ssh/config 文件,但多个 GitHub 帐户有效,如何?

amazon-web-services - 带密码的 AWS ssh key 对

Perl:Net::OpenSSH 的 scp_put 拒绝权限

ssh - 从 PPK 文件创建 PEM

linux - expect Interact 一遍又一遍地读取匹配的行而不继续前进

java - 使用JCraft Jsch - 执行sshpass命令不成功

git - 在没有 VCS 客户端的情况下在本地文件系统上使用远程版本控制 (VCS) 命令