加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

copy_pubkey.sh(非全自动脚本)

发布时间:2020-12-14 05:07:52 所属栏目:大数据 来源:网络整理
导读:#!/bin/bash privkey="$HOME/.ssh/id_rsa" publickey="$HOME/.ssh/id_rsa.pub" # Usage help if [ $# -ne 1 ];then echo "Usage:$0 [[email?protected]]hostname" exit 1 fi # test private/publick key exist or not,and the privilege 600 or not if [ -f
#!/bin/bash privkey="$HOME/.ssh/id_rsa" publickey="$HOME/.ssh/id_rsa.pub" # Usage help if [ $# -ne 1 ];then echo "Usage:$0 [[email?protected]]hostname" exit 1 fi # test private/publick key exist or not,and the privilege 600 or not if [ -f "$privkey" -a -f "$publickey" ];then privkey_priv=`stat -c %a $privkey` if [ "$privkey_priv" -ne 600 ];then echo "The privilege of private key ~/.ssh/id_rsa is not 600,exit now." exit 1 fi else echo "private/public key is not exist,it will create it" ssh-keygen -t rsa -f $privkey -N ‘‘ echo "keys created over,it located on $HOME/.ssh/" fi ssh-copy-id -o StrictHostKeyChecking=no $1 if [ $? -eq 0 ];then echo -e "e[1;32m publickey copy over e[0m" else echo -e "e[1;31mssh can‘t to the remote hoste[0m" exit 1 fi

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读