Every time you have to type the account and password, the repetitive work we are to encapsulate

The following:

Linux environment

A certificate to

  • Enter the terminal
  • Ssh-keygen -t rsa -c “Your email”
  • The generated ID_rsa. pub is the public key and ID_RSA is the private key
  • Copy the code in the public key
  • In the github Personal Center Settings
  • SSH key add new Set a name

Test SSH

  • ssh -T [email protected]
  • Github.com is not bound to host
  • Go to /etc/hosts and add the prompted IP address and domain name of github.com

Ubentu 13.10 Git version 1.8.3.2 SSH -t [email protected] Permission denied (publickey) is displayed. The problem of

Today's task is to upload the project to Github through Git, so the problem of Permission Denied (publickey) appears. Now I share my solution with you. Ssh-keygen: Enter file in which to save the key (" current path "): Enter file in which to save the key SSH -t [email protected]: "Permission denied (publickey)" There are two simple solutions to this problem: 1) Use the name 'id_rsa' when naming the file. 2) If you must name the file yourself, Use ssh-add ~/. SSH/your name _rsa to add your name to SSH. Then use ssh-t [email protected] to see what you want. Hi xx! You've successfully authenticated, but GitHub does not provide shell access.Copy the code

Note: When generating a key, perform operations in ~/. SSH /. Or move the generated file to the ~/. SSH/directory.

You can also run the ssh-add -l command to view the added key list. SSH -v [email protected] View debugging informationCopy the code

If there are any questions or inaccuracies, please timely comment, thank you!

Open the ~ /.ssh/id_rsa.pub file and copy all the contents into your GIthub SSH key

On Github, go to “Edit Your Profile” and find the SSH key. Then add the SSH key and copy it to the key.

How to convert git to SSH

View the current address git remote -v origin https://github.com/yourname/repository.git (fetch) origin https://github.com/yourname/repository.git (push) is set to address the git SSH remote set - url origin Git @ making: USERNAME/OTHERREPOSITROY. Git revision to check the address, after the completion of the configuration for SSH address is correct the git remote - vCopy the code

known_hosts

SSH keeps a ~/. SSH /known_hosts file for every public key you access on your computer. The next time you access the same computer, OpenSSH checks the public key. If the public key is different, OpenSSH will warn you against attacks like DNS Hijack. The case I’ve listed above, that’s the case.

The reason: SSH /known_hsots if you log in to a host using the same IP address, SSH information will be recorded in the ~/. SSH /known_hsots file. If you log in to a host using the same IP address, a conflict warning will appear. You need to manually delete and modify “known_hsots”.

There are two solutions:

  1. Delete “known_hsots” manually;
  2. Add these two lines to the ~/. SSH /config configuration file and restart the server.
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
Copy the code

The advantages and disadvantages:

  1. You need to manually delete the file content every time, some automatic scripts can not run (SSH login failed), but the security is high;
  2. SSH login ignores the access to Known_hsots, but the security is low.

Troubleshoot the problem that sSH-Add is required for every boot on a MAC

1. Use SSH Config

Use different private keys for different domain names

Host github.com User git HostName github.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa Host 172.16.167.252 User git HostName 172.16.167.252 PreferredAuthentications publickey IdentityFile ~/. SSH /xiangbiwen_rsaCopy the code

The pit Host is followed by the @ in the SSH repository address

[email protected]: xiejunping/egg – ts. Git

The content between @ and:

Github git clone git@github:xiejunping/egg-ts.git

So if it’s an IP address, write the corresponding IP address

As for HostName, it is the same as Host in principle, but can be customized if it is bound to the local hosts

Linux Permission 0644 for are too open

If you copied the file from another computer, you will receive an error message because:

Private key file permission is too high, change to 600 good

Run the chmod 600 ~/. SSH /xxx_rsa command