Instead of hard-coding a password in shell script, it’s better to use ssh keys which is more secure
For that
$ scp -i ~/.ssh/id_rsa [email protected]:/path/to/bin/*.derp .
your private key should be at ~/.ssh/id_rsa
To generate a key pair:
$ ssh-keygen -t rsa
This will generate both private and public key in locations
~/.ssh/id_rsa (private key) and ~/.ssh/id_rsa.pub (public key)
To setup the SSH keys for usage (one time task) :
Copy the contents of ~/.ssh/id_rsa.pub and paste in a new line of ~devops/.ssh/authorized_keys in myserver.org server.
If ~devops/.ssh/authorized_keys doesn't exist, create it.
Refer: http://www.linuxproblem.org/art_9.html
If still, this won’t work it means the .ssh dir or the authorized_keys files may not have the right permissions (700). Enable the permissions then you can solve this problem.