This question already has an answer here:

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

echo 'systemPwd' | ssh myMachine@

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

sshpass -p 'systemPwd' ssh myMachine@ <<-'ENDSSH'
    #commands to run on remote host
    echo 'systemPwd' | sudo -S  shutdown-h now

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.

marked as duplicate by Kusalananda, Christopher, roaima, countermode, Archemar Jan 12 '17 at 14:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Alternatively you could set up certificate based authentication and avoid having a password stored in your script. – roaima Jan 12 '17 at 13:00
  • Actually the problem is I want to make this method to work in Colibri T20 OS (angstrom Platform OS). So in that OS ,I'm unable to install the ssh-keygen and ssh pass package in that colibri OS. – aadhithyan Jan 28 '17 at 13:01
  • You don't need either of those packages. You just need some way of generating a certificate pair that you can use in the client and server. – roaima Jan 28 '17 at 20:17
  • Yeah You are right. But in case of ubuntu it's working without any package by simply using the command ssh-keygen . But in angstrom os that ssh-keygen is not available. That's the problem in my scenario. – aadhithyan Jan 30 '17 at 7:23
  • So run ssh-keygen on a different machine; all it does is to generate a pair of keys: one for the client and one for the server. – roaima Jan 30 '17 at 10:28

I recommend you to use SSH Keys.

For creating SSH Keys use this command on the client machine:

ssh-keygen -t rsa 

Then you can copy the public key into the new machine's authorized_keys file with the ssh-copy-id command:

ssh-copy-id myMachine@

After that you can login to your remote machine without password.

for more info: https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2

Not the answer you're looking for? Browse other questions tagged or ask your own question.