I am simply trying to list the directories after I ssh into a remote machine in my rails app but I am not getting the desired output, what is am I overlooking? The host is an IP.
controller-
def index
@ssh_test = Net::SSH.start( :host =>'xx.x.xx.xx',:user => 'name', :password => 'secret' ) do |ssh|
result = ssh.exec!('ls')
puts result
end
end
gemfile-
gem 'net-ssh'
view
<h2><%= @ssh_test %></h2>
Shouldn't the current directories directories print to my view? Thanks for your attention.
UPDATE
Here is updated progress, still don't seem to fully grasp this.
before_filter :set_ssh, :only => [:index]
def index
@ssh_dir = Net::SSH.start( @host, @user, :password => @password ) do |ssh|
result = ssh.exec!('ls')
end
def set_ssh
@host = 'xx.x.xx.xx'
@user = 'user'
@password = 'password'
end
view-
<h1><%= @ssh_dir( host, user, password).inspect %></h1>