Ruby Net :: SSH method indefinite 'shell'
source link: https://www.codesd.com/item/ruby-net-ssh-method-indefinite-shell.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Ruby Net :: SSH method indefinite 'shell'
I'm trying to log into a remote machine using SSH in my Ruby code and then trying to cd into another directory once I SSHed in. Here is my Ruby code to do it
require 'net/ssh'
require 'rubygems'
require 'needle'
Net::SSH.start('host', 'shui', :password => "password") do |ssh|
output = ssh.exec!("hostname")
shell = ssh.shell.open
shell.pwd
shell.cd "/svn"
puts shell.pwd
end
when I run my script, it gives me this error:
testssh.rb:8:in `block in <main>': undefined method `shell' ... (NoMethodError)
I'm pretty sure I've installed the gems that are needed to do this. Any suggestions on how to fix this? Thanks!
There is no shell
method in Net:SSH v2
, the yielded object is a Net::SSH::Connection::Session.
This net-ssh
extension gives you the feature you are looking for: https://github.com/mitchellh/net-ssh-shell
Related Articles
Ruby NET :: SSH - Can not connect to remote server
Net :: SSH :: Shell :: Process $ DONTEVERUSETHIS
Using Ruby and net-ssh, how do I authenticate using the key_data parameter with Net :: SSH.start?
get information from the remote system by using the sudo command using net :: ssh to ruby
Sudo via net :: ssh to ruby
The Net :: SSH sudo command crashes after entering the password
Net-ssh timeout for execution?
How to properly transfer Net :: SSH port
Net :: SSH :: AuthenticationFailed: Authentication Failed for User
Ruby Net-SFTP does not block on download
Delete anything other than file + linked file on multiple servers (NET :: SSH :: MULTI)
Export the path using NET :: SSH: PERL
Ruby net / smtp badly assigned email subject
Ruby net / sftp read the file remotely and save to the database, get StatusException error (4, & ldquo; failure & rdquo;)
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK