实验环境: centos6-1 centos6-2

##################### centos6-1创建密钥对:gpg --gen-key (可以不给密钥加密)时间会比较久 查看密钥对:gpg -list-keys 导出公钥到:jack.pubkey gpg -a --export -o jack.pubkey

将公钥发送给centos6-2: rsync -a jack.pubkey centos6-2:/root/.ssh/

######################################## centos6-2创建密钥对:gpg --gen-key 导入centos6-1的公钥:gpg --import jack.pubkey 查看密钥列表: gpg --list-keys 用centos6-1的公钥对文件加密:gpg -e -r jack test.txt 会生成:test.txt.gpg

将加密文件发送给centos6-1:rsync -a test.txt.gpg centos6:/root/ ####################################################

解密文件并输出:gpg -d test.txt.gpg -o test.txt ###################################################