Home > Enterprise >  How to automatically pass credentials to ssh
How to automatically pass credentials to ssh

Time:09-03

Im trying to ssh into a server, and Im doing this-

ssh reza@osx-m1-1 

But it asks for password in the next line, and I want to automate this process, so I was thinking of using echo to pass my password-

echo mypassword | ssh reza@osx-m1-1 

But this didn't worked, Could you please suggest how to do this without installing extra plugins ?

CodePudding user response:

To do this you need sshpass:

sshpass -p 'mypassword' ssh reza@osx-m1-1

But instead of logging in with the password you should use an ssh key. Generate one with ssh-keygen then use ssh-copy-id reza@osx-m1-1 and from then you should be able to login with simply ssh reza@osx-m1-1

There are other answers for this: https://askubuntu.com/a/46935/541661

  • Related