In older versions of net-ssh there used to be a shell function that allowed
you to open up a shell on the remote host and issue commands. At some point
this was removed
Presently it is possible to issue commands with something like
ssh = Net::SSH.start(...)
ssh.exec!(some command or other)
The problem is each exec! call opens a new shell on each call so it is not
possible to retain your state on the remote machine. The following is not
possible
ssh.exec!('tar -zxf fred.tgz')
ssh.exec!('cd fred')
ssh.exec!('./configure') <- This fails
Being a new shell means that it starts in ~ and not ~/fred. There are ways
around this - massive single line commands like
ssh.exec!('(tar -zxf fred.tgz ; cd fred ; ./configure ; ... ')
Am I missing something or is there another way to open up a shell over ssh?
How about this gem? I haven't tried it but found it with a quick google
search, seems promising. But it also hasn't been updated in a while, I have
no idea how compatible it is with the latest versions of Ruby and Net::SSH.
···
On Mon, Nov 27, 2017 at 2:03 AM Peter Hickman < peterhickman386@googlemail.com> wrote:
In older versions of net-ssh there used to be a shell function that
allowed you to open up a shell on the remote host and issue commands. At
some point this was removed
Presently it is possible to issue commands with something like
ssh = Net::SSH.start(...)
ssh.exec!(some command or other)
The problem is each exec! call opens a new shell on each call so it is not
possible to retain your state on the remote machine. The following is not
possible
ssh.exec!('tar -zxf fred.tgz')
ssh.exec!('cd fred')
ssh.exec!('./configure') <- This fails
Being a new shell means that it starts in ~ and not ~/fred. There are ways
around this - massive single line commands like
ssh.exec!('(tar -zxf fred.tgz ; cd fred ; ./configure ; ... ')
Am I missing something or is there another way to open up a shell over ssh?
You can issue commands via ssh like in the snippet below,
if you have alredy set up authorized_keys.
If not you, could try "expect".
I send tou this snippet, I can't elaborate much more because...
I am just a beginner in Ruby;P
It should retain state because you are sending commands always
to the same process. I did not try, I am in a hurry, and tomorrow
I will not be at the keyboard.
In older versions of net-ssh there used to be a shell function that allowed you to open up a shell on the remote host and issue commands. At some point this was removed
Presently it is possible to issue commands with something like
ssh = Net::SSH.start(...)
ssh.exec!(some command or other)
The problem is each exec! call opens a new shell on each call so it is not possible to retain your state on the remote machine. The following is not possible
ssh.exec!('tar -zxf fred.tgz')
ssh.exec!('cd fred')
ssh.exec!('./configure') <- This fails
Being a new shell means that it starts in ~ and not ~/fred. There are ways around this - massive single line commands like
ssh.exec!('(tar -zxf fred.tgz ; cd fred ; ./configure ; ... ')
Am I missing something or is there another way to open up a shell over ssh?