因为腾讯上suselinux用的是SSH2,所以生成的时候需要用到ssh-keygen2工具,以往用的是(ssh-keygen)。
在A服务器上生成密钥对
ssh-keygen2 -t rsa
提示输入密码,如果需要空密码,直接回车就行。

执行完后会在当前用户的目录下的.ssh2/生成一对密钥,如/root/.ssh2目录下生成id_rsa_2048_a和id_rsa_2048_a.pub
接下来创建两文件

文件名:identification,cat identification #IdKey id_rsa_2048_a#

文件名:authorization文件,cat authorization  #Key id_rsa_2048_a.pub #

文件创建完后,密钥对算是生成完了,接下来就是把公钥上传到需要被管理的服务器上去。如果只需要上传较少的服务器,远程拷贝过去就行了,如果服务器比较多,就用脚本上传

1.建立一个存放服务器ip的文件:ip.txt     cat ip.txt #1.1.1.1 2.2.2.2 .....#

2.建立上传脚本 copy.sh

#!/bin/bash

publicfile='/root/.ssh2/id_rsa_2048_a.pub  /root/.ssh2/authorization'

while read host

do

   echo $host

   scp $publicfile root@$host:/root/.ssh2

done < 'ip.txt'

这样,就完成了。(注意文件权限)