First, the principle of public and private keys
Public and private keys is commonly known as asymmetric encryption .
Objective : 1 content sent encrypted, not to be seen.
2. it must be sent, others can not pretend.
Role : Public key encryption / inspection chapter, the private key to decrypt / signature
Principle : A document sent to B, A using the public key encryption B, B with their own private key to decrypt. Meanwhile, A signature with its private key, B uses the public key of A chapter test . Before a step to ensure the content is sent encrypted and decrypted others can not, because the use of public key cryptography B, only B can be seen. After a step as long as the private key A does not leak, can I send a file to ensure that A, B holds A's public key can view the file contents.
Two, ssh implement password-free
Target : A dense Free log B, may be used to encrypt rsa or dsa
Public and private key pair generation statement: SSH-keygen -t RSA -P ''
Public and private key storage directory: /root/.ssh
Public and private key files: id_rsa private key, id_rsa.pub public key
Step: . 1, A to create public and private key pair
2, copy the public key to B's directory under /root/.ssh authorized_keys file.
scp /root/.ssh/id_rsa.pub [email protected]:/root/.ssh/authorized_keys
3, B authorized_keys file to the machine 600 permissions
chmod 600 authorized_keys
4、A机登录B机
ssh -l root 192.168.56.120