I'm writing a shell script to connect to a Linux based remote machine using ssh
After successfully logging in to the remote machine I'm able to execute Linux commands, now the real problem I'm facing is when trying to run the same script for another remote machine which will ask for a local authentication(username
and password
) upon ssh
login to proceed further.
Can someone guide me on how to fill the first line with my username
and immediately do a carriage return and perform similar action for password
.
I've tried the below code connect.sh
sshpass -p <remote-passwd> ssh root@<remote-ip> 'bash -s' < test.sh
test.sh
contain
ls
pwd
If I run connect.sh
script it executes perfectly without asking for remote machine password. It also executes ls
and pwd
Can I actually replace ls
and pwd
with my username
and password
to achieve what I'm trying to do??
Also, Am I looking on something which is not possible?? (I have seen a similar code in VB.NET which is solving my purpose but it is not a robust code and I really don't have any idea on VB scripts
)
Update: I'm able to login to remote machine non interactively, but the remote machine environment immediately asks for a local authentication which again requires keyboard interaction, I'm looking for achieving this authentication non interactively