Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## I'm lost with the exceptions here, where should they be placed? before
- ## or after the block?; i know they have to rescue the connection and authentication
- begin
- Net::SSH.start( '192.168.1.101',:password=>'john',:port => 22,:username=>'user1') do |session|
- shell = session.shell.sync
- out = shell.send_command( "ls" )
- p out.stdout
- p shell.exit
- end
- rescue SocketError
- raise(IOError, 'Could not connect to host')
- rescue Net::SSH::AuthenticationFailed
- raise(IOError, 'Authentication Failed')
- end
Add Comment
Please, Sign In to add comment