How to enter ssh password using bash?

Every day I connect to the server via ssh. I am reviewing this procedure:

IC001:Desktop user$ ssh user@my.server.com user@my.server.com password: Last login: Tue Jun 4 10:09:01 2013 from 0.0.0.0 $ 

I would like to automate this process and create a bash script to do this for me. I don't care about security and keep my password open in a script well. I also understand very well that it is typed openly on the screen while the script is running. So I created this:

 #!/bin/bash ssh user@my.server.com echo mypassword 

But that will not work. I also tried send instead of echo , but also did not work. Please advise if possible.

+68
bash ssh
Jun 04
source share
2 answers

Double check if you cannot use keys.

Otherwise, use the wait:

 #!/usr/bin/expect -f spawn ssh user@my.server.com expect "assword:" send "mypassword\r" interact 
+139
Jun 04 '13 at 22:38
source share

Create a new key pair: (go by default)

 ssh-keygen 

Copy the public key to the server: (password for the last time)

 ssh-copy-id user@my.server.com 

Now the server should recognize your key and no longer ask for a password:

 ssh user@my.server.com 
+79
Jun 04 '13 at 21:52
source share



All Articles