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 git@github.com:vim/vim.git
Cloning into 'vim'...
Warning: Permanently added the RSA host key for IP address '13.229.188.59' 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 git@github.com
Permission denied (publickey).
Copy Code

Generate a new ssh key

Use the command ssh-keygen to generate paired id_rsa and id_rsa.pub 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/id_rsa.pub: Paired private and public keys
$ ls ~/.ssh
authorized_keys  config  id_rsa  id_rsa.pub  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/id_rsa.pub
ssh-rsa AAAAB3SSSSSSSSSSSSSSSSSSSSSBAQDcM4aOo9qlrHOnh0+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHuM9cYmdKq5ZMfO0dQ5PB53nqZQ1YAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAc1w7bC0PD02M706ZdQm5M9Q9VFzLY0TK1nz19fsh2I2yuKwHJJeRxsFAUJKgrtNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN7nm6B/9erp5n4FDKJFxdnFWuhqqUwMzRa9rUfhOX1qJ1SYAWUryQ90rpxOwXt9Pfq0Y13VsWk3QQ8nyaEJzytEXG7OR9pf9zDQph4r4rpJbXCwNjXn/ThL shanyue
Copy Code

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

More graphic guides can be found in official documents: help.github.com/cn/articles...

Setup Successful

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

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

$ git clone git@github.com:shfshanyue/vim-config.git
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