Ruby脚本Net :: SSH :: HostKeyMismatch但ssh有效
发布时间:2020-12-17 02:57:18 所属栏目:百科 来源:网络整理
导读:我可以ssh到我的aws网络上的远程主机,但使用net / ssh在 ruby脚本中失败.我的gem是Ubuntu 16.04上的net-ssh(4.2.0).即使使用non_interactive =它也不会提示输入密码.假. 错误: Authentication failed for user Net::SSH::AuthenticationFailed 为什么这段代
我可以ssh到我的aws网络上的远程主机,但使用net / ssh在
ruby脚本中失败.我的gem是Ubuntu 16.04上的net-ssh(4.2.0).即使使用non_interactive =>它也不会提示输入密码.假.
错误:
为什么这段代码失败了? #!/usr/bin/env ruby require 'rubygems' require 'net/ssh' HOST = 'myhost' Net::SSH.start(HOST,:auth_methods => ['publickey'],:passphrase => 'mypassphrase',:non_interactive => true,:host_key => "ssh-rsa",:keys => [ '/home/markhorrocks/.ssh/id_rsa' ] ) do |session| output = session.exec!('ls') puts output end 编辑我的代码后,我得到错误
HOST = 'myhost' USER = 'markhorrocks' Net::SSH.start(HOST,USER,:encryption => "blowfish-cbc",:keys => [ '/home/markhorrocks/.ssh/id_rsa' ],:port => '1234',:forward_agent => true,:compression => "zlib@openssh.com" ) do |session| output = session.exec!('ls') puts output end 解决方法
密钥数组需要指向您的私钥. authorized_keys是允许登录当前主机的密钥的公共指纹.此外,您似乎已为host_key设置了私钥类型.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |