2018年9月19日 星期三

rsync免密碼

建立公開金鑰與私密金鑰
$ ssh-keygen -t dsa -b 1024 -f filename.key
Generating public/private dsa key pair.
Enter passphrase (empty for no passphrase):不需輸入密碼
Enter same passphrase again:不需輸入密碼
Your identification has been saved in filename.key.
Your public key has been saved in filename.key.pub.
The key fingerprint is:
1a:81:da:6f:7a:eb:2c:dd:1c:e3:b1:f1:cc:97:4a:33 kelly@orion
The key's randomart image is:
+--[ DSA 1024]----+
|                 |
|     .           |
|    . .          |
|   o   .         |
|  . . . S        |
|     . o=        |
|     .++ XE  .   |
|    .+o =.+oo    |
|    .++.  .o     |
+-----------------+


filename.key
filename.key.pub 放在遠端主機

須將 filename.key.pub 放到遠端 ~/.ssh/authorized_keys 裡

$ cat filename.key.pub >> ~/.ssh/authorized_keys
$ rsync -avz -e “ssh -i filename.key” username@IP:/path1/ /path2/

沒有留言:

張貼留言