Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ConnectionTimeout Error When Using net-ssh With Options that Work with ssh Command?

Tags:

ssh

ruby

net-ssh

I'm trying to use the net-ssh documentation to connect to a remote server. I'm using the following options:

  • :username
  • :port
  • :keys
  • :host

with values set equal to the values of the Host that I have configured in my ~/.ssh/config file that I use for connecting to the same remote server using the ssh command. However, I'm getting an error when trying to run the following line in irb:

session = Net::SSH.start( # my options here # )

Error:

Net::SSH::ConnectionTimeout: Net::SSH::ConnectionTimeout
    from /Users/jake/.gem/gems/net-ssh-4.2.0/lib/net/ssh/transport/session.rb:90:in `rescue in initialize'
    from /Users/jake/.gem/gems/net-ssh-4.2.0/lib/net/ssh/transport/session.rb:57:in `initialize'
    from /Users/jake/.gem/gems/net-ssh-4.2.0/lib/net/ssh.rb:237:in `new'
    from /Users/jake/.gem/gems/net-ssh-4.2.0/lib/net/ssh.rb:237:in `start'
    from (irb):14
    from /usr/local/bin/irb:11:in `<main>'

Is this a configuration/argument error on my part or do I need to call a different command?

like image 847
gr1zzly be4r Avatar asked Sep 18 '26 23:09

gr1zzly be4r


1 Answers

My issue was that I was specifying my arguments incorrectly. If you're using options, you need to specify your host and username as position arguments and then you can use hashes for the rest of the arguments. Doing:

Net::SSH.start('host', 'user', :port => #my port#, :keys => ['/path/to/key'])

worked for me.

like image 184
gr1zzly be4r Avatar answered Sep 20 '26 12:09

gr1zzly be4r



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!