Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I massively use scp and ssh for work. I'm a little bored to insert the password everytime Usually I scp many files from term and I was wondering if there is a way to mantain open the scp connection. I mean, it would be great if there is something like this:

$ scp user@server # to estabilsh the connection
user@server's password:
$ scp file1 user@server:/folder # No password asked!
$ scp close # to close the connection
share|improve this question
up vote 1 down vote accepted

While it may be possible to keep the connection open, the best way of doing this is probably to use public key authentication, which avoids the need to repeatedly type a password.

Assuming both the local and remote machines are running linux:

user@local $ cat .ssh/ | ssh user@remote 'cat >> .ssh/authorized_keys'

Will add the SSH key of the local machine to the list of pre-approved users of the remote machine, and subsequent ssh or scp commands should not require a password.

If you still get asked for a password, you might need to do

user@remote $ chmod 400 .ssh/authorized_keys
share|improve this answer
Hi! Thank you for the answer. I'm going to try it on monday when I'll be back to work! – the_candyman Dec 1 '12 at 15:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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