Net :: SFTP无法通过Ruby控制台连接

时间:2015-02-09 02:37:09

标签: ruby-on-rails ruby ssh console sftp

我正在尝试通过ruby控制台连接到sftp服务器。

代码段:::

Net::SFTP.start(IP, USERNAME, password: PASS) do |sftp|
.....
end

它抛出以下错误::::

Net::SSH::Disconnect: disconnected: No Host (7)
    from /Users/venkatesan/.rvm/gems/ruby-1.9.3-p385@helpkit/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:188:in `block in poll_message'
    from /Users/venkatesan/.rvm/gems/ruby-1.9.3-p385@helpkit/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:178:in `loop'
    from /Users/venkatesan/.rvm/gems/ruby-1.9.3-p385@helpkit/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:178:in `poll_message'
    from /Users/venkatesan/.rvm/gems/ruby-1.9.3-p385@helpkit/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:163:in `next_message'
    from /Users/venkatesan/.rvm/gems/ruby-1.9.3-p385@helpkit/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:95:in `block in next_message'
    from /Users/venkatesan/.rvm/gems/ruby-1.9.3-p385@helpkit/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:94:in `loop'
    from /Users/venkatesan/.rvm/gems/ruby-1.9.3-p385@helpkit/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:94:in `next_message'
    from /Users/venkatesan/.rvm/gems/ruby-1.9.3-p385@helpkit/gems/net-ssh-2.9.2/lib/net/ssh/authentication/methods/none.rb:14:in `authenticate'
    from /Users/venkatesan/.rvm/gems/ruby-1.9.3-p385@helpkit/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:79:in `block in authenticate'
    from /Users/venkatesan/.rvm/gems/ruby-1.9.3-p385@helpkit/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:66:in `each'
    from /Users/venkatesan/.rvm/gems/ruby-1.9.3-p385@helpkit/gems/net-ssh-2.9.2/lib/net/ssh/authentication/session.rb:66:in `authenticate'
    from /Users/venkatesan/.rvm/gems/ruby-1.9.3-p385@helpkit/gems/net-ssh-2.9.2/lib/net/ssh.rb:211:in `start'
    from /Users/venkatesan/.rvm/gems/ruby-1.9.3-p385@helpkit/gems/net-sftp-2.1.2/lib/net/sftp.rb:31:in `start'
    from (irb):143
    from /Users/venkatesan/.rvm/rubies/ruby-1.9.3-p385/bin/irb:16:in `<main>'

我也试过使用Net :: SSH ..得到同样的错误。

但是当我执行sftp USERNAME然后它会提示输入密码时。当我在终端中输入密码时它正确连接。但不能单独通过ruby代码连接。

有人能说些什么吗?

1 个答案:

答案 0 :(得分:0)

终于找到了原因..我给错了参数。它是user @ host。我的参数不正确。

谢谢你们