-->
就是因为懒!我不想每次上传公钥到新系统上时重复那几条命令,当然也是为了高效,呵呵!在使用脚本前请更改变量$locate_key的值,将其设定为你公钥所在文件。
#!/usr/bin/perl -w#名称:pubkey
#用法:pubkey -h hostname [-u username]
use strict;
use Getopt::Std;
my %opt;
my $locate_key="/root/.ssh/pubkeys";
$opt{u}="root";
getopt("hu",\%opt);
print "pubkey -h hostname [-u username]\n",exit unless defined $opt{h};
`ssh $opt{u}\@$opt{h} "if [ -d .ssh ]; then : ;else mkdir .ssh ;fi ;cd .ssh;cat >>authorized_keys" <$locate_key`;

发表评论