Ava
Ava

Reputation: 6043

Net::SSH does not seem to connect to remote host

Following the syntax from http://net-ssh.github.io/net-ssh/

Net::SSH.start('remotehost', 'ava') do |ssh|
  puts `hostname`
end

It prints the name of current hostname rather than remote hostname. What is wrong?

Upvotes: 1

Views: 102

Answers (1)

Arup Rakshit
Arup Rakshit

Reputation: 118261

You should use as below :

Net::SSH.start('remotehost', 'ava') do |ssh|
  puts ssh.host
end

As ssh is an instance of Net::SSH::Connection::Session class And if you browse the documentation,you will get the method #host,which will give you the desired result.

Upvotes: 1

Related Questions