scp (secure copy) to copy files, it asks for passwords. It can get really annoying the fact that the password is asked every time. Fortunately, scp is it's easily scriptable.Suppose we want to copy the file
abc.tgz to an account of a remote machine:scp abc.tgz user@foo:/documentsWe can do it without the need of entering the user password, but still in a secure way thanks to
ssh.- First, generate a public/private key pair on the local machine:
ssh-keygen -t rsa - Then press 
Enterand leave blank the passphrase (since we don't want one). Your public key has been saved in~/.ssh/id_rsa.pub  - Copy the content of public key 
id_rsa.pubjust generated to the remote machine. You can usescpto make the copy. If you are logging in as a user, it would be in/home/user/.ssh/authorized_keys. Notice that theauthorized_keysfile can contain keys from other PCs. So, if the file already exists and contains text, you need to append the contents of your public key file to what already is there. 
Ref: Linux Journal, Jayakara Kini's Weblog