I have a script with ssh commands that are using a jump host:
scp -J user@jump file admin@server
ssh -J user@jump admin@server "touch hello"
I would like to ask for the passwords only once and tried sshpass
:
sshpass -p "PasswordForJump" scp -J user@jump file admin@server
This will only ask the password for admin@server. However, since there are two ssh/scp commands, I still have to enter the admin password twice.
I tried to nest the sshpass
but the script is blocked:
sshpass -p "PasswordForJump" sshpass -p "PasswordForServer" ssh -J user@jump admin@server
Naively I have tried to set the two passwords in a file (one per line) by expecting sshpass
to use one after the other but this fail too.
Can I use sshpass
to supply two passwords ?