4

I have keys configured such that I can login to SVN_HOST like this:

ssh <USER_NAME>@<SVN_HOST>

Will log me to SVN_HOST with no password prompt. So far so good; however:

svn update svn+ssh://<USER_NAME>@<SVN_HOST>/<PATH_TO_REPO> <DEST_PATH>

Still prompts for:

<USER_NAME>@<SVN_HOST>'s password: 

When I enter the password it works as I expect; however, I don't understand why it insists on prompting for password on the svn+ssh case.

Thanks in advance.

EDIT: As requested, Verbose SSH out put via:

SVN_SSH="ssh -v " svn update svn+ssh://<USER_NAME>@<SVN_HOST>/<PATH_TO_REPO> <DEST_PATH>

Results in:

OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to <SVN_HOST> [<SVN_HOST>] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.1p1 Debian-5ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA cd:32:17:49:fa:19:aa:64:57:91:76:0d:76:19:82:2f
debug1: Host '<SVN_HOST>' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Next authentication method: password

Then prompted for password:

<USER_NAME>@<SVN_HOST>'s password: 

After entering password:

debug1: Authentication succeeded (password).
Authenticated to <SVN_HOST> ([<SVN_HOST>]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LC_MESSAGES = en_CA.UTF-8
debug1: Sending env LC_COLLATE = en_CA.UTF-8
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending env LC_CTYPE = en_CA.UTF-8
debug1: Sending command: svnserve -t
At revision <REV_NUM>.

Key Gen was done like so:

ssh-keygen

Using defaults then:

ssh-copy-id -i ~/.ssh/id_rsa.pub <USER_NAME>@<SVN_HOST>
SMTF
  • 165
  • 2
  • 6
  • Please provide SSH debug output by running `svn` like this: `SVN_SSH="ssh -v " svn update svn+ssh://...`. – mgorven Nov 02 '12 at 00:01
  • @mgorven Sure. Edited question. – SMTF Nov 02 '12 at 00:14
  • Where is your SSH key stored and how have you made it be used when using `ssh` directly? – mgorven Nov 02 '12 at 00:15
  • @mgorven Re-edited question – SMTF Nov 02 '12 at 00:20
  • 1
    Did you generate the key as root? When running under `svn`, `ssh` is looking for `/root/.ssh/id_rsa` -- does that exist? Which user are you running `svn` as? – mgorven Nov 02 '12 at 00:30
  • @mgorven No. I made the key on the client and then ssh-copy-id'd the key to the host. I see your point. What I don't understand is why ssh works using the key in one case (with no svn) and doesn't in the other (the one with svn). – SMTF Nov 02 '12 at 00:35
  • 1
    Are you running `svn` as root or under `sudo`? – mgorven Nov 02 '12 at 00:36
  • I suggest you seriously look at setting up an SSH agent rather then just keys alone. The agent makes a lot of this easier. – Zoredache Nov 02 '12 at 00:38
  • @mgorven Yes. I'm running svn under sudo on the client. I have also now tried creating the keys with sudo (no change). – SMTF Nov 02 '12 at 00:44
  • @Zoredache I'll prob. end up doing something like that. What is bothering me is that this config. works without svn but fails with it. – SMTF Nov 02 '12 at 00:45

1 Answers1

5

You generated the key as a normal user so it is stored in /home/bob/.ssh/. You're running svn as root however under sudo, and so the SSH client is looking for keys in /root/.ssh/. You either need to run svn as your normal user, copy the key to /root/.ssh/, or configure ssh to look for keys elsewhere:

sudo SVN_SSH="ssh -i /home/bob/.ssh/id_rsa " svn update ...
mgorven
  • 30,615
  • 7
  • 79
  • 122