Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
rucao
committed
Nov 17, 2020
1 parent
5e52a85
commit 65d9c17
Showing
6 changed files
with
67 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# create public key & secret key | ||
createSshkey() { | ||
mkdir -p /opt/ssh | ||
chown -R $1:$2 /opt/ssh | ||
|
||
ssh-keygen -t rsa -f /opt/ssh/id_rsa -P '' -C $1 | ||
local privateKeyFile="/opt/ssh/id_rsa" | ||
chmod 600 ${privateKeyFile} | ||
|
||
mkdir -p /home/$1/.ssh | ||
local publicKeyFile="/home/$1/.ssh/authorized_keys" | ||
cat /opt/ssh/id_rsa.pub >>${publicKeyFile} | ||
chown -R $1:$2 /home/$1/.ssh | ||
chmod 755 ${publicKeyFile} | ||
|
||
echo -e "\033[41;36m OK: create public key & secret key done. \033[0m" | ||
} | ||
|
||
|
||
|
||
# let's go | ||
username="cachecloud-open" | ||
password="cachecloud-open" | ||
if [[ $# > 0 && -n "$1" ]]; then | ||
username="$1" | ||
echo -e "\033[41;36m please set password for user: ${username} \033[0m" | ||
stty -echo | ||
read password | ||
stty echo | ||
fi | ||
echo -e "\033[41;36m use username: ${username}. \033[0m" | ||
# create public key & secret key | ||
createSshkey "${username}" "${password}" |