aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/scripts/ssh.sh
diff options
context:
space:
mode:
Diffstat (limited to 'dotfiles/scripts/ssh.sh')
-rwxr-xr-xdotfiles/scripts/ssh.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/dotfiles/scripts/ssh.sh b/dotfiles/scripts/ssh.sh
new file mode 100755
index 0000000..7116490
--- /dev/null
+++ b/dotfiles/scripts/ssh.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+#By default the sshd listen only for local connection.
+
+if [[ $1 == "disable" ]]; then
+ if [[ $(cat /etc/ssh/sshd_config | grep -e "^ListenAddress") == "" ]]; then
+ sudo sed -i -e 's/#ListenAddress ::/#ListenAddress ::\nListenAddress 127.0.0.1/g' /etc/ssh/sshd_config
+ sudo systemctl restart sshd.service
+ fi
+ echo "sshd listen now only for local address 127.0.0.1."
+elif [[ $1 == "enable" ]]; then
+ sudo sed -i -e '/ListenAddress 127.0.0.1/d' /etc/ssh/sshd_config
+ sudo systemctl restart sshd.service
+ echo "sshd listen now for all address."
+elif [[ $1 == "status" ]]; then
+ echo $(sudo systemctl status sshd.service)
+ echo "sshd conf say:"
+ echo $(cat /etc/ssh/sshd_config | grep -e "^ListenAddress")
+elif [[ $1 == "start" || $1 == "stop" || $1 == "restart" ]]; then
+ sudo systemctl $1 sshd.service
+fi
+
+sudo -k
+