1

I'm using this link to install git-core, gitolite and gitweb in ubuntu 12.04:
https://ao2.it/wiki/How_to_setup_a_GIT_server_with_gitolite_and_gitweb
I installed git-core by using this command:

sudo apt-get install git-core  

Then I added a new user git by using this command:

sudo adduser \
    --system \
    --shell /bin/bash \
    --gecos 'git SCM user' \
    --group \
    --disabled-password \
    --home /home/git \
    git  

Then I added repositories in /home/git

sudo -u git mkdir /home/git/repositories  

Then I moved to windows machine, and generated pub and ppk keys by using this command:

ssh-keygen -t rsa  

Then I copied pub key to ubuntu and added it to /home/<username>/.ssh/ folder.
Then I ran scp command in windows cmd:

scp C:/Users/Ajay Kulkarni-enEXL/.ssh/id_rsa.pub 192.168.1.140:git.pub  

git is the new user name in Ubuntu which I created earlier.
Output of that command was:

You can't hack this system from external connectors like putty telnet etc.!!

Good luck with hacking this system cheers :)
Ajay Kulkarni-enEXL@192.168.1.140's password:
Permission denied, please try again.
Ajay Kulkarni-enEXL@192.168.1.140's password:
Permission denied, please try again.
Ajay Kulkarni-enEXL@192.168.1.140's password:
Permission denied (publickey,password).
lost connection  

And I got this stackdump:

Exception: STATUS_ACCESS_VIOLATION at eip=61050C17
eax=00000000 ebx=616D16C8 ecx=0000000B edx=00000000 esi=0028E870 edi=002F0028
ebp=0028E708 esp=0028E6E0 program=C:\Program Files (x86)\OpenSSH\bin\ssh.exe, pid 6924, thread main
cs=0023 ds=002B es=002B fs=0053 gs=002B ss=002B
Stack trace:
Frame     Function  Args
0028E708  61050C17  (616D16C8, 00000001, 0028E870, 00000001)
0028E768  610A341F  (00000004, 00000001, 0028E870, 00000020)
0028E8B8  6108DF2F  (0028ED10, 0028E8D0, 00000400, 00000002)
0028ECE8  00428777  (0028ED10, 00000000, 004104F5, 100E8C78)
0028EDB8  0041058A  (0028EE20, 0000004F, 00000000, 0028EE34)
0028EDD8  0040FD53  (0028EE20, 100EF838, 0028EE20, 0041B469)
0028EE08  0041AA08  (00000000, 0028EE34, 0028EE20, 0040F7A4)
0028EE68  0040FBD8  (100E8C60, 100E8C78, 100E8C48, 004391B0)
0028F038  004023A0  (00000001, 616D2744, 100E00A8, 0028F090)
0028F078  61005F54  (0028F090, 00570056, 00590058, 007B005A)
0028FF58  6100616B  (00000000, 00000000, 00000000, 00000000)
End of stack trace  

scp was unable to connect to ubuntu instance. How can I make scp connect to ubuntu?

Ajay Kulkarni
  • 2,900
  • 13
  • 48
  • 97

1 Answers1

1

Then I copied pub key to ubuntu and added it to /home/<username>/.ssh/ folder

You would actually need to add it to /home/git/.ssh/authorized_keys (with the right permission, as seen here

server$ mkdir ~/.ssh
server$ chmod 700 ~/.ssh
server$ cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
server$ chmod 600 ~/.ssh/authorized_keys
server$ rm ~/id_rsa.pub

).

Test your ssh connection with

ssh -Tv git@192.168.1.140

You must be able to open an ssh session as git, before proceeding any further.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • with right permissions? You want me to do a `chmod 777`? – Ajay Kulkarni Oct 06 '16 at 09:16
  • No: read http://stackoverflow.com/a/37626619/6309 and http://stackoverflow.com/a/13428529/6309 – VonC Oct 06 '16 at 09:26
  • There was no `authorized_keys` file in `.ssh` folder. So I directly ran `cat ~/id_rsa.pub >> ~/.ssh/authorized_keys` and changed permissions and removed `id_rsa.pub`. Then I moved to windows and executed scp command with double quotes around file path. I got this output: `ssh: C: no address associated with name` – Ajay Kulkarni Oct 06 '16 at 09:37
  • Right, the syntax is wrong. Let me check again in a bit (on my phone right now) – VonC Oct 06 '16 at 09:42
  • Okay... I tried without double quotes and `scp` asked for password. I was surprised because I had given a passphrase while key generation. Nevertheless, I gave ubuntu's password and it refused to connect. Why? – Ajay Kulkarni Oct 06 '16 at 10:11
  • @AjayKulkarni I have edited my answer. Actually, the git.pub needs to go into the git account on your Ubuntu server. – VonC Oct 06 '16 at 10:38
  • "I gave ubuntu's password and it refused to connect.": it asks you a password because you try to open a session as a user who does not exist on the server (`Ajay Kulkarni-enEXL` instead of `git`): when ssh cannot communicate authentication through public/private key, it falls back to username/password. Which does not work here since the only user registered on Ubuntu is the one your created: git. – VonC Oct 06 '16 at 10:40
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/125093/discussion-between-ajay-kulkarni-and-vonc). – Ajay Kulkarni Oct 06 '16 at 10:44