Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

In a bash script, I have several rsync statements. Every rsync will prompt for typing password, and defeats very much the automation of doing the job using a script. How to improve this? The destination path of rsync statements are either network drive connected via SAMBA or on a SSH server.

share|improve this question

migrated from Jul 26 '12 at 1:07

This question came from our site for professional and enthusiast programmers.

What OS are you running that script in? From the comments below, I guess OS X, but I wouldn’t want to answer without you specifying it. – kopischke Aug 3 '12 at 9:25
up vote 3 down vote accepted

Generate a SSH key pair, upload the public half to the server, and put the private half in the local agent.

share|improve this answer
What if the server is not SSH accessible? In Mac OS X 10.6.8, I connect to smb:// via Finder (Go -> Connect to Server menu option). – qazwsx Jul 23 '12 at 19:07
SMB URLs accept a username and password. – Ignacio Vazquez-Abrams Jul 23 '12 at 19:08
Do you mean put my user name and password explicitly in my Bash script like smb:// – qazwsx Jul 23 '12 at 19:09

The generic method for repeating the same string in shell is:

yes "string" ¦ command args

Or for non-repetitive, complex string:

echo -e "first\nsecond\n..." ¦ command args
share|improve this answer

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.