0

My code is

c = Net::SSH.start("192.168.x.x", "admin", :password=>"xyz")
puts c.exec "sh run"

c.close

Executing this I get "Error getting tty, exiting". What is the issue here, please help me.

Thanks, Jade

Jade
  • 41
  • 6

1 Answers1

0

This is happening because admin user on remote host doesn't have shell associated with it, so when you login ssh is getting that error while running the command.

Login to the remote machine and set a valid shell for the admin user or use a different user who has valid shell associated with it.

Also its good practice to specify the full path of the binary that you need to invoke, so instead of 'sh' its better to us '/bin/sh'.

Saurabh
  • 76
  • 1
  • Can you please help how to set valid shell ? I can login as root on the same server with out any issues, but I cant run this(another) command as root. – Jade Mar 20 '15 at 22:30
  • 'sh run' what this command should be doing by the way? if you logged in as root and cannot run the command then you should check what shell root is running as, "echo $SHELL" should tell you about the shell. Also to change shell refer to this : http://stackoverflow.com/questions/13046192/changing-default-shell-in-linux – Saurabh Mar 21 '15 at 00:14
  • as root, echo $SHELL, says its at /bin/bash. so should this allow root to execute some command which admin can? – Jade Mar 24 '15 at 20:57