Cloud Server ssh key management and github configuration

A word programmers often say is: Programming for github.Without github, programmers can see how important it is to them.

The tool that works with github is git, in the previous chapter git installation and basic configuration on cloud servers There is also a basic introduction to it on the server.Although git can work on both ssh and https protocols, ssh is more often chosen for security and convenience.

If you use https, you need to authenticate every git push

The main content of this article is:

  1. ssh keygen generates public-key and private-key in asymmetric encryption
  2. Throw publik-key on github, as in the previous article Server efficient login configuration Same steps, but here's how to throw key s to the cloud server, and here's github.

Once you're familiar with the process, it only takes a minute to complete

Permission denied (publickey).

If you do not set the public key on github and execute the git clone command directly, you will have permission problems.

Testing connectivity using ssh-T is as follows, with a Permission denied exception.

$ git clone
Cloning into 'vim'...
Warning: Permanently added the RSA host key for IP address '' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

# But there's a more direct command to see if you have permission
$ ssh -T
Permission denied (publickey).
Copy Code

Generate a new ssh key

Use the command ssh-keygen to generate paired id_rsa and File, only id_after generationRsa.pubThrow it into github.

# Generate an ssh-key
# -t: optional dsa | ecdsa | ed25519 | rsa | rsa1, representing encryption
# -C: Notes, usually write your own mailbox
$ ssh-keygen -t rsa -C "shanyue"

# Generate id_rsa/ Paired private and public keys
$ ls ~/.ssh
authorized_keys  config  id_rsa  known_hosts
Copy Code

Add a new ssh key to the github settings

Copy ~/.ssh/id_in Cloud ServerRsa.pubThe contents of the file are pasted into the github configuration.

$ cat ~/.ssh/
Copy Code

In github's ssh keys settings: Click New SSH key to add the public key you just generated.

More graphic guides can be found in official documents:

Setup Successful

Successful ssh-T testing allows you to successfully and happily program to github without worrying about copying code.

$ ssh -T
Hi shfshanyue! You've successfully authenticated, but GitHub does not provide shell access.

$ git clone
Cloning into 'vim-config'...
remote: Enumerating objects: 183, done.
remote: Total 183 (delta 0), reused 0 (delta 0), pack-reused 183
Receiving objects: 100% (183/183), 411.13 KiB | 55.00 KiB/s, done.
Resolving deltas: 100% (100/100), done.
Copy Code

Pay attention to me

I'm Shanyue and I regularly share a full stack of articles on my Personal Public Number.If you are interested in Personal Server Operations and Maintenance, you can either add me to WeChat shanyue94 to communicate with me or note Personal Server to join the Personal Server Operations and Maintenance Discussion Group

Keywords: ssh github git vim

Added by dev99 on Thu, 28 May 2020 05:35:54 +0300