首页 > 其他 > 详细

ssh免密脚本

时间:2017-09-11 16:01:22      阅读:288      评论:0      收藏:0      [点我收藏+]
#!/bin/sh

if [ "$1"x = ""x ]; then
    echo "usage:/opt/bin/auto-ssh.sh user server"
else
    user=$1
    server=$2
    pubkey=`cat ~/.ssh/id_rsa.pub`
    if [ "$pubkey"x = ""x ]; then
       ssh-keygen
       pubkey=`cat ~/.ssh/id_rsa.pub`
    fi
    cmd="mkdir -p ~/.ssh && chmod 700 ~/.ssh && [ ! -e \‘~/.ssh/authorized_keys\‘ ] && touch ~/.ssh/authorized_keys&&echo \"$pubkey\" >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
    ssh $user@$server \`$cmd\`
fi

 

ssh免密脚本

原文:http://www.cnblogs.com/wangmo/p/7505318.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!