The below command works fine from my localhost and I get the desired output. See below
$ ssh -o ConnectTimeout=7 -o BatchMode=yes email@example.com "echo WORKS;exit" Output: WORKS
Now, I put this command in a script file
test.sh having sufficient execution privileges
$ cat test.sh segment=$(ssh -o ConnectTimeout=7 -o BatchMode=yes firstname.lastname@example.org "echo WORKS;exit") echo "SEGMENT $segment"
I don't get the desired output. Infact I get the below error:
$ ./test.sh Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). SEGMENT
I was expecting
Now, the Permission denied error goes away but
Can you please suggest what could be the issue ?