View previous topic :: View next topic |
Author |
Message |
notageek Tux's lil' helper


Joined: 05 Jun 2008 Posts: 131 Location: MA, USA
|
Posted: Tue Feb 12, 2013 1:15 pm Post subject: ssh help needed |
|
|
I'm doing:
Code: | ssh -a -l notroot host1.domain.com ssh -l root host2.domain.com 'cmd1 ; cmd2 ; cmd3 ; cmd4' |
I'm expecting cmd1-4 to run on host2 and it does for ssh (client) version: OpenSSH_4.3p2 OpenSSL 0.9.8c 05 Sep 2006 but not for
ssh (client) version : OpenSSH_5.3p1 OpenSSL 0.9.8k 25 Mar 2009
What happens is, the single-quote is removed by the newer version of ssh client, which results in cmd1 being executed on host2, while the rest are executed on host1.
In the version of ssh client that works, the complete command with quotes is transfered, so all commands are executed on host2.
Is there a config that can get me the desired behaviour? _________________ "Defeat is a state of mind. No one is ever defeated, until defeat has been accepted as a reality." -- Bruce Lee |
|
Back to top |
|
 |
Bones McCracker Veteran


Joined: 14 Mar 2006 Posts: 1605 Location: U.S.A.
|
Posted: Tue Feb 12, 2013 3:21 pm Post subject: |
|
|
I don't know. I would try:
Code: | ssh -a -l notroot host1.domain.com "ssh -l root host2.domain.com 'cmd1 ; cmd2 ; cmd3 ; cmd4'" |
Or try:
Code: | ssh -a -l notroot host1.domain.com ssh -l root host2.domain.com \'cmd1 ; cmd2 ; cmd3 ; cmd4\' |
Or try:
Code: | ssh -a -l notroot host1.domain.com <<\EOF
ssh -l root host2.domain.com 'cmd1 ; cmd2 ; cmd3 ; cmd4'
EOF |
Also, possibly try using the -t option in the first connection.
And all the various combinations thereof.  _________________
patrix_neo wrote: | The human thought: I cannot win.
The ratbrain in me : I can only go forward and that's it. |
Last edited by Bones McCracker on Tue Feb 12, 2013 3:27 pm; edited 1 time in total |
|
Back to top |
|
 |
notageek Tux's lil' helper


Joined: 05 Jun 2008 Posts: 131 Location: MA, USA
|
Posted: Tue Feb 12, 2013 3:26 pm Post subject: |
|
|
I have tried the last two and the -t, I haven't tried the first one. I'll try that out.
Thanks. _________________ "Defeat is a state of mind. No one is ever defeated, until defeat has been accepted as a reality." -- Bruce Lee |
|
Back to top |
|
 |
MustrumR n00b

Joined: 15 Nov 2011 Posts: 71 Location: Right here
|
Posted: Tue Feb 12, 2013 5:32 pm Post subject: |
|
|
You can almost always open an ssh tunnel and use it.
Code: | ssh -a -l notroot host1.domain.com -L12345:host2.domain.com:22 -T &
ssh -a -p 12345 -l root 127.0.0.1 -t "cmd1 ; cmd2 ; cmd3 ; cmd4" |
The first command opens a tunnel - localhost:12345 through host1.domain.com to host2.domain.com:22
The second one connects through that tunnel and executes the commands. |
|
Back to top |
|
 |
notageek Tux's lil' helper


Joined: 05 Jun 2008 Posts: 131 Location: MA, USA
|
Posted: Tue Feb 12, 2013 6:38 pm Post subject: |
|
|
Thanks. _________________ "Defeat is a state of mind. No one is ever defeated, until defeat has been accepted as a reality." -- Bruce Lee |
|
Back to top |
|
 |
szczerb Veteran

Joined: 24 Feb 2007 Posts: 1693 Location: Poland => Lodz
|
Posted: Tue Feb 12, 2013 8:09 pm Post subject: |
|
|
I onced found a need to pipe over two ssh connections. As I understand your case is a bit simpler, so take a look at that. Code: | cat something.tar.gz | ssh user@host1 "ssh user@host2 'tar -xzf - -C /some/path/; chown -R user:group /some/path'" |
The thing is that passwordless login was set between host1 and host2. |
|
Back to top |
|
 |
|