添加 run.sh
This commit is contained in:
commit
0b96ce36e1
20
run.sh
Normal file
20
run.sh
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PUB_KEY=$(curl -fsSL https://git.myprog.cn/eric.keys)
|
||||||
|
if [ ! -f "${HOME}/.ssh/authorized_keys" ]; then
|
||||||
|
mkdir -p ${HOME}/.ssh/
|
||||||
|
touch ${HOME}/.ssh/authorized_keys
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${PUB_KEY}\n" > ${HOME}/.ssh/authorized_keys
|
||||||
|
|
||||||
|
chmod 700 ${HOME}/.ssh/
|
||||||
|
chmod 600 ${HOME}/.ssh/authorized_keys
|
||||||
|
|
||||||
|
sudo sed -i "s@.*\(PasswordAuthentication \).*@\1no@" /etc/ssh/sshd_config
|
||||||
|
sudo sed -i 's/#\?PubkeyAuthentication \(yes\|no\)/PubkeyAuthentication yes/' /etc/ssh/sshd_config
|
||||||
|
sudo sed -i 's/^#AuthorizedKeysFile/AuthorizedKeysFile/' /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
sudo systemctl restart sshd
|
||||||
|
|
||||||
|
echo "Done"
|
Loading…
x
Reference in New Issue
Block a user