I know that this question has been proposed several times (https://superuser.com/questions/606252/how-to-use-sshpass-for-chained-connection and https://unix.stackexchange.com/questions/320412/how-to-use-sshpass-to-supply-a-password-on-the-second-ssh-hop) but all the solutions that I've found until know are not working. I'm tryng to access a third machine (third@machine) by using sshpass in order to not be prompted to insert a password. However,it is mandatory to use a bridge machine (bridge@machine) before entering the final one. Each time I need to enter the passwords for the bridge@machine and for the third@machine, so my workflow is:
ssh bridge@machine
insert password:
ssh third@machine
insert password
Until now, I was able to avoid the first password by using sshpass in the proxycommand inside the ~.ssh/config file as follow:
vi ~.ssh/config :
Host *.reference
User example_user
ProxyCommand sshpass -p $bridge_machine_password$ ssh -o StrictHostKeyChecking=no bridge@machine "nc -w 60 `basename %h .reference` %p"
and contemporary I've define an alias named "curie" in the .bashrc file which is:
alias curie='ssh third@machine.reference'
So if run the alias curie I'm able to avoid the first password but I'm still prompted for the password of the third@machine.
For this reason I've tried to use sshpass to access the third@machine in the following manner:
>sshpass -p 'third_machine_password' ssh -oProxyCommand="ssh -W %h:%p bridge@machine" third@machine
Unfortunately, this gives back :
Permission denied, please try again.
Could be a restriction imposed by the third@machine or I'm doing something wrong?