I am trying to run a nested ssh -t -t but it won't provide me the environment variables when working with cat and echo.
#!/bin/bash
pass="password\n"
bla="cat <(echo -e '$pass') - | sudo -S su -"
ssh -t -t -t -t jumpserver "ssh -t -t -t -t server \"$bla\" "
I get an output without any variables taken into consideration. (e.g. PS1 does not get shown but commands work fine) The problem is related to cat <(echo -e '$pass') - but this was the way to keep echo alive after providing the password for sudo.
How can i achieve this and get environment variables to get a proper output?
Thanks.
                        
The
-ttis enough. Using more-tdoes not add any more effect and just makes an impression that you have no idea what are you doing.What is the point of
cat <(echo -e)construction? Writing justechowould result in the same, isn't it?Why to use
sudo su?sudoalready does all you need, isn't it?So how can it look in some fashionable manner?
And does it work? Try to debug the commands with
-vvvswitches to thessh. It will show you what is actually executed and passed to each other shell.