I want to login to a remote system in ubuntu using a script file which will be executed in my system . The script contains the following commands
#!/bin/bash
echo 'systemPwd' | ssh [email protected]
By executing this script I could not log in to the system. It doesn't gets the password from the echo command. But I don't know how to use alternatives.
But I tried this script
#!/bin/bash
sshpass -p 'systemPwd' ssh [email protected] <<-'ENDSSH'
#commands to run on remote host
echo 'systemPwd' | sudo -S shutdown-h now
ENDSSH
In the above script the sshpass has been used. The problem is that sshpass has to be installed first. Anyone suggest an alternative method for this which would make me to connect to remote system without sshpass.
ssh-keygenon a different machine; all it does is to generate a pair of keys: one for the client and one for the server.