I have script that runs remote login using SSH, copies a file from that remote machine using SCP without asking for a password, however, the change only works for the terminal where I am running the script. If I try to execute this same script on a different terminal, it will prompt me for a password.

Is there a way I can create a script that will prompt for my password once, then not ask for my password the next time the script is run?


Use the ssh-copy-id [user@]machine command to install your public key in the remote machine's authorized_keys.


ssh is rather paranoid of its passwords. You can use its drop-in replacement from putty, it allows to load password from file or even command-line.


You can setup a master SSH connection that accepts multiplexing connections. See the options -M and -S of the SSH client manual.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.