Reputation: 1025
I need to ssh into a server and su with password within that server and then ssh into another server from there. I am not able to su with password after I ssh into my first server via bash script. Normally what I do in terminal is,
$ ssh server1
logged in to server1$ su user
password: ******
switched to corresponding user$ ssh server2
How can I automate this process by switching user with password in bash?
Upvotes: 0
Views: 697
Reputation: 2615
Can sudo without password works for you?
ssh abc@$xyz "
echo '
set -vxe
# Your script here
' | sudo /bin/bash"
Upvotes: 1
Reputation: 219
Have you tried this?
sshpass -f <(printf '%s\n' "yourpassword") ssh username@server "\"sshpass -f <(printf '%s\n' "yourpassword") ssh username@server"
Upvotes: 1