2

I have recently installed on my Ubuntu dedicated a Gitlab server.

Webapp is working fine, I had no trouble during the installation (tested on VM before production environment)

I have uploded my ssh rsa private key from the web app on my account, and created a project, clone from another repository.

From my desktop environment, I have tried to git pull using ssh. First login, I had to accept the ssh fingerprint, then, until now server keep asking me to log in as git user, which has no password.

D:/drive/project> git pull git@0.0.0.0:me/project.git
git@0.0.0.0's password:
Connection closed by 0.0.0.0
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

D:\skydrive\artmoser>git pull
git@0.0.0.0's password: [tried to type something]
Permission denied, please try again.
git@0.0.0.0's password:
Permission denied, please try again.
git@0.0.0.0's password:
^C

My ssh public and private key under windows is in C:\Users\Jack Bauer.ssh On the dedicated server I can see my key in /home/git/.ssh/authorized_keys

I have checked my chmod for user git :

drwx--x--x  7 git     git     4096 mai   31 05:06 git/
drwx------  2 git  git  4096 juin   1 03:27 git/.ssh/
-rw------- 1 git git  508 juin   1 02:53 git/.ssh/authorized_keys

What am i doing wrong ?

EDIT

After more research :

If I log in with git user with putty, I receive this error message server refused to allocate pty

If I try to do ssh git@0.0.0.0, they ask for my passphrase, 3 times before git user password (which has none)

If I do a ssh tunnel with ssh git@0.0.0.0 -Tvvv , i get this errror at the end of the log

debug1: Next authentication method: publickey
debug1: Trying private key: /home/me/.ssh/id_rsa
debug1: key_parse_private2: missing begin marker
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Enter passphrase for key '/home/me/.ssh/id_rsa':
Dimitri Kopriwa
  • 13,139
  • 27
  • 98
  • 204

1 Answers1

3

the public key is on my computer, the private is on the server,

If you want to access a server with ssh, your client (here your Windows workstation) must have at least the private keys (and it is a good practice to keep the public keys together with their private keys counterparts).

C:\Users\Jack Bauer\.ssh\id_rsa.pub
C:\Users\Jack Bauer\.ssh\id_rsa

If your keys don't follow this default naming convention, you will need a C:\Users\Jack Bauer\.ssh\config file (as illustrated there)

Make sure you have the HOME environment variable set to C:\Users\Jack Bauer in your Windows shell when you are typing those command: that is the case if you launch the git-cmd.exe (which comes with any Git For Windows distribution)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I did place the two files with the exact same name, I had to remove my github ssh key. I still can't log in, but now he ask me for a passphrase for key. I didn't set one, so I had to make a new key, but it still reject the passphrase. – Dimitri Kopriwa Jun 01 '14 at 05:35
  • @BigDong no need for passphrase, make sure you have a private key without a passphrase (for testing purpose), and that your public key is published on the server side in the `~git/.ssh/authorized_keys` file. – VonC Jun 01 '14 at 05:37
  • @BigDong then you can debug ssh as illustrate in http://stackoverflow.com/a/23173608/6309 or http://stackoverflow.com/a/22740720/6309 – VonC Jun 01 '14 at 05:39
  • Thanks for the links, but still, i can't ssh in command line, with windows, I have to use putty. Using putty with the ssk key with git@maserver:22 return this error "server refused to allocate pty", and putty close – Dimitri Kopriwa Jun 01 '14 at 05:49
  • @BigDong you were able to ssh to GitHub though? (before moving your GitHub keys). Note that you can have multiple sets of ssh key with a config file (http://stackoverflow.com/a/7550935/6309) – VonC Jun 01 '14 at 06:53
  • 1
    @VonC actually, having just the private key on the client is sufficient – guido Jun 01 '14 at 14:36
  • @guido while that might be true technically, the best practice would be to keep both closely together on the client (or you have to `ssh-keygen -y` each time you want to publish your public key: http://askubuntu.com/a/53555/5470). – VonC Jun 01 '14 at 15:03
  • /home/git/.ssh/authorized_keys has the option "no-pty", so it should be correct that putty doesn't work. – Vincent.StreamComputing Aug 07 '14 at 11:04
  • @BigDong see Vincent's comment: http://stackoverflow.com/questions/23976078/git-ssh-ask-for-a-password-with-gitlab/23976901?noredirect=1#comment39207894_23976901 – VonC Aug 07 '14 at 11:12
  • @Vonc that's true, however, "our client [...] must have both public and private keys" is broadly different from "the good practice is that". – Jocelyn delalande Dec 09 '15 at 14:49
  • @Jocelyndelalande I agree and I have amended my answer accordingly – VonC Dec 09 '15 at 14:50