0

Recently I started working on a Raspberry Pi 2 to host some simple webapps and to host a gitlab-server. Both seemed to be working fine until the point where I wanted to clone a repo from gitlab. I.e. I'm trying to clone a repo on my RasPi2, that is hosted on my RasPi2. I generated an ssh-key and added it in my gitlab account. I then tried to clone a repo but I get permission denied errors continuously.

For clearance sake: every command is executed on my RasPi2; I'm connected to it through ssh from my regular desktop pc.

Any help clearing this up would be wonderful, thanks in advance.

Rien Heuver
  • 170
  • 1
  • 12
  • What does `ssh -v ` say? Likely, ssh doesn't see or accept the private part of your key – user3159253 Dec 27 '15 at 02:22
  • Using ssh with the git-user (`git@`) actually worked. Cloning the repository gave the following: `fatal: could not create work tree dir 'RasPi-landing-page'.: Permission denied`. (RasPi-landing-page is the repo-name.) – Rien Heuver Dec 27 '15 at 13:45
  • Hence it's the _client_ problem which isn't related to network interaction. I would start from creating an empty repo on the RPi, pushing the repo data from the clone on your PC to the RPi, and then try to reset the working tree on the RPi. Well comments aren't suitable place to explain complex things :) – user3159253 Dec 27 '15 at 17:54

1 Answers1

0

/var/www/html usually belongs to a different user (e.g. root) than your current login, this is the root of the problem. So you either should act from another user (use sudo bash for that) or should put your repo in a different place, or should set the ownership and permissions of /var/www/html so that your regular ssh session could write to the folder (use chown and/or chmod for this).

For dealing with unix permissions you may find this qa useful

Community
  • 1
  • 1
user3159253
  • 16,836
  • 3
  • 30
  • 56
  • I think that your steps above can't really work. If I create a repo somewhere on my RasPi and then try to clone that repo on my working pc, how is my working pc going to know where to clone from? Since I never registered that repo with gitlab in the first place. Anyway, I tried some things out here 'n there and it looks like I actually got somewhere. I can currently clone on my RasPi that's hosted on my RasPi. However, I want to clone it into /var/www/html and it asks for the password of the git-account, which should be authenticated through ssh. I'm kind of lost in the maze now... – Rien Heuver Dec 27 '15 at 21:28
  • I started searching based on the above answer and found the problem: when trying to clone into `/var/www` I used `sudo` (since the regular user doesn't have write permission there). However, the git-command will then look for ssh-keys in `/root/.ssh` instead of ~`//.ssh`. Thus I needed an ssh-key for root. I fixed it by copying the user's ssh-keys with `sudo cp ~//.ssh/id_* /root/.ssh/`. From there on I could use `sudo git` with the already registered ssh-keys. – Rien Heuver Dec 31 '15 at 11:38
  • Glad to hear that you've found the problem – user3159253 Jan 01 '16 at 04:03