Hi all,

I am really new in bash scripting and I can't even make simple tasks

What I am trying to do is executing a command (ls -l for this example), over a double leap ssh.

ssh -T myuser@entrypoint ssh -T myuser@targetpc<<EOI
 ls -ltr .

I did the following script before and it works, but since I need a double leap it is not useful at all

ssh -T myuser@targetpc<<EOI
 ls -ltr .

My naive assumption was that it would be just adding another ssh to the line

Thank you!

5 Years
Discussion Span
Last Post by thekashyap

Sorry, I should have posted the errors too

I am promted for the entrypoint password, and after entering successfully this is what I get

Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,gssapi-with-mic,password).


Have you setup passwordless ssh between entry-point and target machines?
If not I'm surprised that you got any output as I would expect that when ssh -T myuser@targetpc is executed it hangs instead of giving permission denied. But then the IO redirection with SSH is always shaky/complex to understand.
Perhaps first ssh didn't create any input stream when it executed second ssh, which in turn wanted the password. And thus the second one executed immediately without password and failed. But this is of course guess..

What I would usually do while dealing with remote machines is to
- create a one liner script, which does what I want then
---- The script ensures that it puts all output in some "output file".
- copy this (via rcp/scp) to the remote machine
- execute the script with ssh
- fetch the "output file", parse and find the result.

This is purely for reliability and working around the thousand issues that ssh has with IO redirection.

In your case if you do this it would surely help to point out where the problem is. You'll get better understanding of the flow and which command is doing what. (of course I assume that you'll make your one liner script write enough log messages to output file_:) )

Edited by thekashyap: added some guesses abt the error.. :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.