Instead of a hard-coded password in a shell script, use SSH keys, it is simpler and safer.
$ scp -i ~/.ssh/id_rsa devops@myserver.org:/path/to/bin/*.derp .
if your private key is in ~/.ssh/id_rsa
To create a public / private key pair:
$ ssh-keygen -t rsa
The above will generate 2 files, ~/.ssh/id_rsa (private key) and ~/.ssh/id_rsa.pub (public key)
To configure SSH keys for use (one-time task): Copy the contents of ~/.ssh/id_rsa.pub and paste ~devops/.ssh/authorized_keys into the myserver.org server in a new line. If ~devops/.ssh/authorized_keys does not exist, feel free to create one.
A clear instruction manual is available here .
Pradeep Pati Apr 24 '13 at 20:32 2013-04-24 20:32
source share