From e44b5399b79e4c3ef58b4f8f029c7d0589eaff3a Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Sun, 24 May 2020 12:17:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96GCP=5FSSH=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init_GCP_ssh.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 init_GCP_ssh.sh diff --git a/init_GCP_ssh.sh b/init_GCP_ssh.sh new file mode 100755 index 0000000..6413fa6 --- /dev/null +++ b/init_GCP_ssh.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# bash <(curl -L -s https://raw.githubusercontent.com/mack-a/v2ray-agent/master/init_GCP_ssh.sh) +if [[ -z `find ~/.ssh -name authorized_keys` ]] +then + echo -e "\033[36m 初始化 authorized_keys \033[0m" + mkdir -p ~/.ssh + touch ~/.ssh/authorized_keys + chmod 600 ~/.ssh/authorized_keys +fi + +sed -i '1iRSAAuthentication yes' /etc/ssh/sshd_config +if [[ ! -z `cat /etc/ssh/sshd_config|grep -v grep|grep -n "PermitRootLogin no"|awk -F "[:]" '{print $1}'` ]] +then + deleteLine=`cat /etc/ssh/sshd_config|grep -v grep|grep -n "PermitRootLogin no"|awk -F "[:]" '{print $1}'` + sed -i "${deleteLine}d" /etc/ssh/sshd_config +fi +service sshd restart