Official Note: https://help.github.com/articles/generating-ssh-keys/
1. Set SSH key for GitHub account
Article Address: http://zuyunfei.com/2013/04/10/setup-github-ssh-key/
What is SSH key
has been using SSH to connect to the server, but the principle of it is not very understanding. This time setting octopress, you need to use SSH to connect to GitHub, just about how SSH works. (It's like GitHub recommends using HTTPS to access repo, before GitHub was attacked by SSH keys, then the security of SSH key is upgraded, HTTPS is more convenient and secure, but the Octopress setup document I did not find how to use HTTPS to connect to GitHub)
In simple terms, SSH provides two levels of security validation:
- The first level is password-based security authentication, knowing the account number and password, you can log on to the remote host. The team's development effort is to use this method to log on to the build server, or to develop the machine. Because it is in the intranet, this level of security verification is sufficient.
- The second level is based on the security validation of the Public-key cryptography (public key encryption) mechanism, as shown in the following principle:
The advantage is that no shared universal key is required, and the decrypted private key is not sent to any user. Even if the public key is intercepted on the internet, it cannot be decrypted if there is no private key that matches it, and the public key being intercepted is useless.
Generate SSH Key
Depending on the help documentation provided by GitHub, the process is as follows
12 |
CD ~/.ssh# Checks to see if there are a directory named ". SSH" in your user directory |
Using Ssh-keygen to generate a new key
1234 |
"[Email protected]" inwhich to save the key (/HOME/YOU/.SSH/ID_RSA): |
Use the default file name direct Enter, press the prompt to enter the password (if you do not provide a password, SSH will be no password connection, if private key leaks may have security issues)
12 |
For no passphrase): [Type a passphrase]enter same passphrase again: [Type passphrase again] |
Key Creation Success
1234 |
In/home/you/.ssh/id_rsa.pub.the key fingerprint is:0f:f4:3b:ca:85:d6: 17:a1:7d:f0: :9d:f0:a2:db [email protected] |
Upload public key to your GitHub account
- Sign in to GitHub
- In the top right, click the Accounting settings icon
- Select SSH Key
- Click Add SSH Key
In the interface that appears, fill in the name of the SSH key, fill in a name you like, and then paste the contents of the ~/.ssh/id_rsa.pub file into the key column, click on the "Add Key" button.
Add a process github will prompt you to enter your GitHub password once
Set up 403 ports for SSH to use HTTPS
SSH port 22 in the LAN may be blocked by the firewall, you can set SSH to use HTTPS 403 port.
To test whether an HTTPS port is available
123 |
443 [Email Protected]hi username! You'vesuccessfully authenticated, but GitHub does notprovide shell access. |
Edit the SSH configuration file ~/.ssh/config as follows:
123 |
Host github.com Hostname ssh.github.com 443 |
Test is configured successfully
123 |
$ ssh-t [email Protected]hi username! You'vesuccessfully authenticated, but GitHub does notprovide shell access. |
SSH key switching for multiple github accounts
If you want to log on to multiple github accounts on a single machine, you'll need some configuration, although it's not available now, but let's write it down for a rainy day, see here.
2, "GitHub" solves the need to enter username and password for each push code to GitHub
On GitHub, build a project test, go to the homepage to see what you can see
If you use https:
Create a new repository on the command line
https://github.com/guochy2012/test.gitgit push -u origin master
Push an existing repository from the command line
https://github.com/guochy2012/test.gitgit push -u origin master
If you are using SSH:
Create a new repository on the command line
[email protected]:guochy2012/test.gitgit push -u origin master
Push an existing repository from the command line
[email protected]:guochy2012/test.gitgit push -u origin master
Using HTTPS requires you to enter a password each time, SSH does not, but SSH needs to configure the key.
For information on how to generate a key, see the generating SSH keys article
3,github address changed from HTTPS to SSH
Open the command-line tool, run git remote set-url origin
for example:
1234 |
$ git remote set-URL origin git@GitHub. COM:user/repo. git |
Then commit again, if something like this happens:
1234 |
Permission denied (publickey). |
If your SSH key is not set or has expired (for example, after upgrading to the Mountain Lion system), please re-refer to the official documentation above for setup.
4, execute pull times wrong
[Email protected]:~/github/collect$ git pull
Warning:permanently added the RSA host key for IP address ' 192.30.252.130 ' to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ warning:unprotected PRIVATE KEY file! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/home/wangkongming/.ssh/id_rsa ' is too open.
It is recommended this your private key files are not accessible by others.
This private key would be ignored.
Bad Permissions:ignore key:/home/wangkongming/.ssh/id_rsa
Permission denied (PublicKey).
Fatal:the remote end hung up unexpectedly
Answer: Http://stackoverflow.com/questions/1556119/ssh-private-key-permissions-using-git-gui-or-ssh-keygen-are-too-open
Because the authority to give Id_rsa is too high, change to 700 on it. And some say 600.
You changed the permissions in the whole directory, which I agree with Splash are a bad idea. If You can remember what the original permissions for the directory is, I would try to set them back to that and then do The following
cd ~/.sshchmod 700 id_rsa
Inside the. SSH folder. That would set the Id_rsa file to rwx (read, write, execute) for the owner, and zero access for everyone else.
If you can ' t remember what the original settings is, add a new user and create a set of SSH keys for that user, thus Crea Ting a new SSH folder which would have the default permissions. You can use this new SSH folder as the reference for permissions to reset your. SSH folder and files to.
If that doesn ' t work, I would try doing a uninstall of msysgit, deleting all. SSH folders on the computer (just for safe Measure), then reinstalling Msysgit with your desired settings and try starting over completely (though I think you told M E tried this already).
Edited:also just found this link via Google – fixing "warning:unprotected PRIVATE KEY file!" on Linux while it ' s target Ed at Linux, it might help since we ' re talking liunx permissions and such.
How to submit code to your Git account