這篇文章給大家分享的是有關shell中copy_pubkey.sh非全自動腳本的示例分析的內(nèi)容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
#!/bin/bash privkey="$HOME/.ssh/id_rsa" publickey="$HOME/.ssh/id_rsa.pub" # Usage help if [ $# -ne 1 ];then echo "Usage:$0 [user@]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 host\e[0m" exit 1 fi
感謝各位的閱讀!關于“shell中copy_pubkey.sh非全自動腳本的示例分析”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
另外有需要云服務器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。