Get the App
SLTechnology News&Howtos  ›  Servers  › 

Example Analysis of copy_pubkey.sh non-automatic script in shell

Shulou Source: shulou.com Published: 2022-06-01 02:59:07 09月22日 Update

This article shares with you the content of the sample analysis of copy_pubkey.sh non-fully automated scripts in shell. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

#! / bin/bashprivkey= "$HOME/.ssh/id_rsa" publickey= "$HOME/.ssh/id_rsa.pub" # Usage helpif [$#-ne 1]; then echo "Usage:$0 [user@] hostname" exit 1fi# test private/publick key exist or not, and the privilege 600or notif [- 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 fielse 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/" fissh-copy-id-o StrictHostKeyChecking=no $1if [$?-eq 0]; then echo-e "\ e [31mssh can't to the remote host\ e [0m" exit 1fi thanks for reading! This is the end of this article on "sample analysis of copy_pubkey.sh non-automatic scripts in shell". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Tags: Fully automatic examples scripts analysis content more articles good practical articles read knowledge reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Information macOS OPPO Reno Microsoft