How to set the ssh key to the user git while installing gitolite on Ubuntu 10.10
I am trying to configure a git server on an Ubuntu Server 10.10 with gitolite and following the tutorial On Ubuntu for Gitolite.
I first create a user git with the following command : sudo adduser git
Then, I generate a rsa key with the command : ssh-keygen
, I call it id_rsa_git
.
After that, I want to associate it to the user git with the following command :
ssh-copy-id -i ~/.ssh/id_rsa_git.pub git@localhost
The prompt asks me the password for the user git, and after giving it (the good one), I get the following error :
Permission denied, please try again.
I cannot go further s开发者_如何学Pythonince I am pretty noob in Linux administration. Can anybody help me ?
Thanks.
You should not add git.pub to the authorized_keys file. You do that with gl-setup git.pub. If you add the git.pub key by your self you can have lots of problems. gl-setup does it for you and also adds it to your admin repository.
Simply try to copy your key:
cd
sudo cp .ssh/id_rsa_git.pub ~git/.ssh/authorized_keys
If doesn't work, open an other console:
sudo su - git
cd
mkdir .ssh
You can close this console.
sudo chown git:git ~git/.ssh/authorized_keys
sudo chmod 600 ~git/.ssh/authorized_keys
And now all will be good (no need of ssh-copy-id)
Try:
- going with the default naming convention (`id_rsa.pub`, not `id_rsa_git.pub`) - passing the parameter for the public key without the `.pub` extension
For instance:
ssh-copy-id -i ~/.ssh/id_rsa_git git@localhost
or
ssh-copy-id -i ~/.ssh/id_rsa git@localhost
(if you have generated the private/public key with the default naming convention).
(Note: make sure you generate those keys as you, not as root ;) )
The password you have set for the user is not the same as the one you are typing at the prompt for ssh-copy-id
, try resetting the password on the git
account.
Alternatively you can copy the id_rsa_git.pub
file to ~git/.ssh/authorized_keys
and set the permissions chmod 600 ~git/.ssh/authorized_keys; chmod 700 ~git/.ssh; chown git:git ~git/.ssh
, this will all need doing as root (or use sudo
).
精彩评论