Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to write a simple bash script that will update an SVN working copy in a given directory. The repository is accessed with the svn+ssh protocol. The basic process this needs to follow is:

#!/bin/bash

# temporarily relax firewall
iptables -I OUTPUT -p tcp --dport 12345 -j ACCEPT

svn up /path/to/working/copy
# prompt for ssh password will be here

# close firewall again
iptables -I OUTPUT -p tcp --dport 12345 -j REJECT

What I'm stuck on his how to tell my bash script to supply the password to SSH when prompted. Typing the password on the line after the svn up command, predictably, doesn't work.

Is this even possible? If not, alternative ways of achieving this goal will be appreciated.

P.S. I know I should be using SSH public/private key authentication, but the person who runs the server that hosts the SVN repo isn't interested in setting this up for me!

share|improve this question
1  
This might help: askubuntu.com/questions/92981/… –  Caesium Feb 22 '12 at 15:03

1 Answer 1

up vote 2 down vote accepted

P.S. I know I should be using SSH public/private key authentication, but the person who runs the server that hosts the SVN repo isn't interested in setting this up for me!

Well that's very mean! I assume you have SSH access to do this though. Most modern installations of OpenSSH don't require any setup on the server to be done (past installing it). I would seriously consider just attempting to set up a SSH key first:

ssh-keygen
ssh-copy-id username@remotehost

Then just try ssh username@remotehost. If it logs you in, magic, if it doesn't, you've only lost a minute of your life :)

After that you've got options like expect and sshpass which are much worse because you're hard-coding your password in plaintext. Yuk.

share|improve this answer
    
Well I never expected to be able to set up proper SSH key authentication without root access to the remote server! You've just saved me a big headache -- and the slightly worrying prospect of storing my SSH passwords in plain text -- thanks! :-) –  Sam Hastings Feb 22 '12 at 16:35
    
Glad it worked! –  Oli Feb 22 '12 at 16:41

Your Answer

 
discard

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.