How to set ssh key to git user when installing gitolite on Ubuntu 10.10

I am trying to configure a git server on Ubuntu Server 10.10 using gitolite and following a tutorial on Ubuntu for Gitolite .

First I create the git user with the following command: sudo adduser git
I set a password for this user.

Then I generate the rsa key with the command: ssh-keygen , I call it id_rsa_git .

After that, I want to associate it with the git user using the following command:

 ssh-copy-id -i ~/.ssh/id_rsa_git.pub git@localhost 

The request asks me for the password for the git user, and after providing it (good), I get the following error:

 Permission denied, please try again. 

I can’t go any further since I’m pretty free in Linux administration. Can anybody help me?

Thanks.

+4
source share
4 answers

Just try copying your key:

CD

sudo cp.ssh ​​/ id_rsa_git.pub ~ git /. ssh / authorized_keys

If it doesn’t work, open another 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 everything will be fine (no ssh-copy-id needed)

+1
source

You should not add git.pub to authorized_keys file. You do this with gl-setup git.pub. If you add the git.pub key yourself, you can have many problems. gl-setup does this for you and also adds it to your admin repository.

+2
source

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 created a private / public key with a default naming convention).

(Note: make sure you create these keys as you, not as root;))

+1
source

The password that you set for the user does not match the one you enter on the command line for ssh-copy-id , try resetting the password in your git account.

Alternatively, you can copy the id_rsa_git.pub file to ~git/.ssh/authorized_keys and set the chmod 600 ~git/.ssh/authorized_keys; chmod 700 ~git/.ssh; chown git:git ~git/.ssh permissions chmod 600 ~git/.ssh/authorized_keys; chmod 700 ~git/.ssh; chown git:git ~git/.ssh chmod 600 ~git/.ssh/authorized_keys; chmod 700 ~git/.ssh; chown git:git ~git/.ssh chmod 600 ~git/.ssh/authorized_keys; chmod 700 ~git/.ssh; chown git:git ~git/.ssh , all this needs to be done with root privileges (or use sudo ).

0
source

Source: https://habr.com/ru/post/1340170/


All Articles