Add git user and setup ssh key
$ sudo adduser git --disabled-password
$ ssh-keygen -t rsa
$ sudo mkdir /home/git/.ssh
$ sudo mv ~/.ssh/id_rsa.pub /home/git/.ssh/authorized_keys
$ sudo chown -R git:git /home/git/.ssh
$ sudo chmod 600 /home/git/.ssh/*
$ sudo chmod 700 /home/git/.ssh
Add your repositories
$ ssh git@localhost
$ mkdir myproject
$ cd myproject
$ mkdir first.git
$ cd first.git
$ git --bare init
Make SSH more secure
This has been extensively covered by the excellent Slicehost tutorial, but just to recap:
Edit the SSH config:
$ sudo vi /etc/ssh/sshd_config
And change the following values:
Port 2207
...
PermitRootLogin no
...
AllowUsers myuser git
...
PasswordAuthentication no
Where 2207 is a port of your choosing. Make sure to add this so your Git remote:
$ git remote add origin ssh://git@localhost:2207/~/myrepo.git
沒有留言:
張貼留言