Super User is a question and answer site for computer enthusiasts and power users. 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

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 stackoverflow.com 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://host.com/mydir 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://foouser:bar@host.com/mydir? – 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .