1

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!

1

1 Answer 1

2

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.

3
  • 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! :-) Feb 22, 2012 at 16:35
  • Glad it worked!
    – Oli
    Feb 22, 2012 at 16:41
  • In adition to that you could try to use sshfs, with this you can mount the SVN to e.g. /home/someuser/svn-repo This means you just have to type the password once, or even use your shiny key and as long as you leave your machine online, you could work with this folder as it if would live in your home on your machine.
    – s1mmel
    May 19, 2018 at 22:44

You must log in to answer this question.

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