Keypoints
- Public key and Private key are generated simultaneously.
- Private key can descrypt the messages which can be enscrypted by Public key.
- We can generated random nuaambers to test the consistency of the two keys.
1. symmetric encryption
data encryption method whereby the same key is used to encode and decode information.
2. asymmetric encryption (public-key cryptography)
Asymmetric cryptography, which can also be called public-key cryptography, uses private and public key to encrypt and decrypt the data. Public key is the one of the keys in the pair that can be shared with everyone, whereas Private key is the other key in the pair that is kept secret. Any key can be used to encrypt a message then the other key, which is not used for encryption, is used fo decryption.
- When the public key has been sent to the Client, the communication will be built secured.
Question?
How to certify the public key of the server?
- certifyed by the third party(CA)(http -> https).
- self identify.
- Certifyed after the first request by validating the hosts, then input passwd at each log.
- Add the public key to the Server and autoconfirm by 'random number justify'.
3. Certifyed by Public(Github)
The following is the specific process.
a. Preparation
We generate the public key and private key in the Client simultaneous and add public key to the Server.
b. Certification
- When the Client want to communicate with the Server, it send request.
- The Server receive the information and generate the random number A, it will be secured by public key, and get B, B will be sent to the Client.
- Client will get the result $\hat A$ by private and then be sent to the Client.
- Server compare A and B, if $A=\hat A$, the Server will admit to establish contact.
4. Setting (using vscode)
Refer to the vscode documentary
-
In Client: generate a seperate SSH key in a different file
windowns
ssh-keygen -t rsa -b 4096 -f "C:\Users\inlizard\.ssh\id_rsa-remote-ssh"
linux
ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa-remote-ssh
(github) ssh-keygen -t rsa -C 'in...@github.com' -
In Client Vscode : set Remote-SSH: Open Configuration File
-
In Server:
- mkdir $HOME.ssh (/root/.ssh !!!).
- vi authorized_keys.
- copy the public key. #scp C:\Users...... *@*.*:/../.../.../
- chmod 600 to the file.
Wrapping up
Study without thinking and you will get lost,
think without studying and you will fall into danger.
[1]SSH公钥原理(密钥,秘钥,私钥)(看了还是懵逼啊!)
[2]https://www.ledger.com/academy/blockchain/what-are-public-keys-and-private-keys
[3]https://code.visualstudio.com/docs/remote/troubleshooting#_improving-your-security-with-a-dedicated-key
[4]https://www.educba.com/asymmetric-encryption/
[5]https://www.zhihu.com/question/274342316/answer/459200588