采用RSA非對稱加密算法:
如果,A要和B通訊,則:
(1). A通過RSA算法生成公鑰(.pub)和私鑰(公鑰用於加密,私鑰用於解密)
(2). B將A的公鑰文件(.pub)內容加入到authorized_keys中
(3). 此時A便可以向B進行通訊,而B不能向A進行通訊
首先在A機器上生成秘鑰:
ssh-keygen -t rsa (都按默認值)
生成后的秘鑰和公鑰一般在/root/.ssh/目錄中。
其次,將生成公鑰傳給B機器
ssh-copy-id -i /root/.ssh/id_rsa.pub 192.xxx.xxx.xxx
最后測試:
ssh 192.xxx.xxx.xxx
傳輸:
scp root@192.xxx.xxx.xx:/home/abc.zip /home/