Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to do a passwordless ssh connection for a subversion project. Right now I'm using ssh+svn, and it's a little annoying, because I have to type the password any time I want to transact with the server.

I've found several tutorials on the web about how to generate a key for passwordless ssh, but they all seem to assume that I'm using the same username on the remote system as I am for my home system. However, the username that I use for ssh+svn is different that the user account name on the system that I'm running. How do I set this up properly? I haven't had luck with just changing the name in the key file.

share|improve this question
add comment

3 Answers

up vote 12 down vote accepted

You just have to supply the other system's username in the svn command:

$ svn co svn+ssh://otheruser@othersystem/path/to/repo

To answer your question's title, too:

$ ssh otheruser@othersystem

This causes sshd on the remote machine to look in ~otheruser/.ssh/authorized_keys for the public key corresponding to the private key on the machine you're typing the command on.

share|improve this answer
1  
So part of the instructions were to make a file .ssh/id_rsa.pub, and upload it to the remote server. When I made it, it ended with localusername@localsystem. That should be changed to remoteusername@remotesystem, right? Both locally and remotely? –  user394 Aug 19 '10 at 14:05
5  
No. Just append the contents of your local id_rsa.pub to authorized_keys on the remote system. It'll work. –  Warren Young Aug 19 '10 at 14:33
1  
alternately, many systems have ssh-copy-id to solve this problem: "ssh-copy-id -i ~/.ssh/id_rsa.pub username@remote-machine" –  Matt Simmons Aug 19 '10 at 15:12
    
Unfortunately, many do not, and it seems this is not a standard part of OpenSSH, so there are at least a couple of different implementations of this script floating around. –  Warren Young Aug 19 '10 at 15:29
    
If you are using gnome seahorse have automated deployment of keys. –  Maciej Piechotka Aug 19 '10 at 16:29
add comment

There are two ways to do this:

1) put user@ into the svn url ; this tells svn+ssh to login as that user. I think it's kind of a bad idea from a maintenance perspective because things like externals that point at other parts of the repository won't work correctly.

2) make a ~/.ssh/config (documented as ssh_config) that says something like:

Host othersystem
  User otheruser

this way any attempt to ssh to othersystem will default to using otheruser. Which is handy for you when do ssh manually as well as when you're using svn.

share|improve this answer
add comment

You don't have to have the same username on both mashines. As long as you generate the key (ssh-keygen) you have to copy line from ~/.ssh/id_rsa.pub or ~/.ssh/id_dsa.pub (depending on type of key) from local server and append it to ~/.ssh/authorized_keys on remote.

% ssh-keygen
% cat ~/.ssh/id_*.pub | ssh remoteuser@remoteserver 'cat > .ssh/authorized_keys'

If you don't want to type remoteuser each time append to ~/.ssh/config:

Host remoteserver
    User remoteuser

PS. The name of key may be in form of localuser@localhost but it is only a name. It can be just as well myfavouritekey@myfavouritecomputer and noone would care.

share|improve this answer
    
The "cat" command above is the core of the common but nonstandard ssh-copy-id script mentioned above. I recognize it because not all the systems I use come with ssh-copy-id, so I've typed something like that more than a few times. :) –  Warren Young Aug 19 '10 at 17:06
    
I've never heard about ssh-copy-id. I usually use vim or seahorse ;) –  Maciej Piechotka Aug 19 '10 at 17:40
add comment

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.