Reference:
GitHub help:connecting to GitHub with SSH
Liaoche's official website: building a git server
Novice Tutorial: Git Server Setup
1. Installation record (may be wrong ...) )
Local ( Debian 8.8):
sudo Install gitgit version # ensures proper installation
" Little Fish " [email protected]: "[email protected] "
# Initial settings, as variables stored locally, will be used in the Git commit log
[Email protected]:~git config user.namelittle fish[email protected]:~git Config user.email [email protected]163. com
Generate SSH key (this is not a git command!) ),
[Email protected]:~# Ssh-keygen -t rsa-c "[email protected]" Generating Public/private RSA key pair. Enterfile inch whichTo save the key (/root/.SSH/id_rsa): Enter Passphrase (empty forno passphrase): Enter same passphrase Again:your identification has been savedinch/root/.SSH/Id_rsa. Your public key has been savedinch/root/.SSH/id_rsa.pub.The Key fingerprint is: -: f3:c5: .: -: A: 3f: A: $: FC: Wu: C7:DF: 4c:9c: -[email protected] # has been changed, only as a demonstration of the key's Randomart image is:+---[RSA2048]----+| .*.. +o. e...| | o.++ +o. o| | . oo + +. + || .. o =. o| | S. || . || || || |+-----------------+
In short, the local hold the private key, remote hold the corresponding public key, so that both sides can communicate securely. You can refer to this document for the mailbox parameters (it's a tag for SSH key, which is useful when the warehouse is on GitHub). The password is for the private key.
VPS (Centos 6 x86 BBR):
[[email protected] ~]#yuminstall git~]# git version
Copy the "public key" of the "terminal" with access, one line at a
Cat /root/. ssh/id_rsa.pubssh-rsa aaaab3nzac1yc2eaaaadaqabaaabaqdgetajdc9ktmrrlw+++ve+ w4gamjh2lfnc9qja/lbvxufko1atjcqxn2dlanvqxrmvssahrno2mmnnxrp9vi8sg6kawgvkx6n60mamxvmugkzv+bom8ds+c5m+ jadrzjbzfdgwimgdqzfyfg1shntg6jgvzcxj9dignb+ 2cho20cxhcv5jksn2fhzyc75bgut8gxz7e9vtqnwywlnnse8mcfmc28kmxxo14eduzpbdgneu12bo+ufvqybefvnlvcs8x2gijg/ IY5PDCPSCPI0IYZGOR7AKI0SJFHQUC4UMDVIDWC5GP8CQUDXP [email protected]
sudo adduser git
cd/home/ git mkdir . ssh /home/git/. SSH/authorized_keys
sudo git init--bare sample.gitin /home/git/ sample.git/
For security reasons,
sudo chown -R git:git sample.git/etc/passwd
2. Basic operationTry
[Email protected]:~# git clone [email protected]your IP address:/home/git/sample.git
Cloning into ' sample ' ...
Ssh:connect to host your IP address Port 22:connection refused
Fatal:could not read from remote repository.
Sure you have the correct access rights
and the repository exists.
---------------------------------------------------------------------------------------
[Email protected]:~# eval $ (ssh-agent-s)
Agent PID 16083
[Email protected]:~# ssh-add ~/.ssh/id_rsa
Enter Passphrase For/root/.ssh/id_rsa:
Bad passphrase, try again For/root/.ssh/id_rsa:
Identity added:/root/.ssh/id_rsa (/ROOT/.SSH/ID_RSA)
[Email protected]:~# ssh-t [email protected]your IP address
Ssh:connect to host your IP address Port 22:connection refused
---------------------------------------------------------------------------------------
[Email protected]:~# ssh-t [email protected]
The authenticity of host ' github.com (192.30.253.112) ' can ' t be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Is you sure want to continue connecting (yes/no)? Yes
warning:permanently added ' github.com,192.30.253.112 ' (RSA) to the list of known hosts.
Permission denied (PublicKey).
---------------------------------------------------------------------------------------
Change the rookie tutorial to start over and fail
Change a VPS Follow the rookie tutorial re-knock on the success.
[Email protected]:~# Groupadd Git[email protected]:~# useradd git-g Git[email protected]:~# cd/home/git/[email protected]:/home/git#mkdir.SSH[email protected]:/home/git#chmod 755.SSH[email protected]:/home/git#Touch.SSH/Authorized_keys[email protected]:/home/git#chmod 644.SSH/Authorized_keys[email protected]:/home/git# CD/Home[email protected]:/home#mkdirGitrepo[email protected]:/home#ChownGit:git gitrepo/[email protected]:/home# CD Gitrepo[email protected]:/home/gitrepo#git init-- bare runoob.gitInitialized empty git repository in/home/gitrepo/runoob.git/[email protected]:/home/gitrepo#Chown- R git:git runoob.git # Necessary! Otherwise you will not be able to push[email protected] Because of insufficient permissions:/home/gitrepo#vim/home/git/. ssh/authorized_keys
[Email protected] Mingw64/d/labs
$ git clone [email protected]????????????:/ Home/gitrepo/runoob.git
Cloning into ' runoob ' ...
Warning:you appear to has cloned an empty repository.
3. Application
Storing items that are unwilling to be made public
Save important files conveniently as a network disk
Linux Notes #06 # Self-built git repository on VPS