aboutsummaryrefslogtreecommitdiff
path: root/scripts/.scripts
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2017-11-03 09:17:47 +0100
committerneodarz <neodarz@neodarz.net>2017-11-03 09:17:47 +0100
commit820c88c2377ffbdf3029643e62e8cbf477b461b7 (patch)
tree35f7caf0794fb8b55d49e408d1bb73af63b07606 /scripts/.scripts
parent4f61eb2e25c5556a2eeb43f9e713955086b2b5e3 (diff)
downloaddotfiles_ascii-820c88c2377ffbdf3029643e62e8cbf477b461b7.tar.xz
dotfiles_ascii-820c88c2377ffbdf3029643e62e8cbf477b461b7.zip
Add ssh script
Diffstat (limited to 'scripts/.scripts')
-rwxr-xr-xscripts/.scripts/ssh.sh23
1 files changed, 18 insertions, 5 deletions
diff --git a/scripts/.scripts/ssh.sh b/scripts/.scripts/ssh.sh
index 8bd7596..7116490 100755
--- a/scripts/.scripts/ssh.sh
+++ b/scripts/.scripts/ssh.sh
@@ -1,10 +1,23 @@
#!/bin/sh
-sudo
-if [[ $1 == "enable" ]]; then
- sed -i -e 's/#ListenAddress ::\nListenAddress 127.0.0.1/#ListenAddress ::/g' /etc/ssh/sshd_config
-elif [[ $1 == "disable" ]]; then
- sed -i -e '/ListenAddress 127.0.0.1/d' /etc/ssh/sshd_config
+#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