From 601728bd751cde9f13005c1615c60c30e3c4463e Mon Sep 17 00:00:00 2001 From: ston1th Date: Mon, 21 Sep 2015 22:38:25 +0200 Subject: [PATCH] bug fixes and chmod 755 on brightness.sh --- brightness.sh | 0 ssh-config.sh | 24 ++++++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) mode change 100644 => 100755 brightness.sh diff --git a/brightness.sh b/brightness.sh old mode 100644 new mode 100755 diff --git a/ssh-config.sh b/ssh-config.sh index 5c46f55..d839f95 100755 --- a/ssh-config.sh +++ b/ssh-config.sh @@ -1,13 +1,12 @@ #!/bin/bash if [ ${EUID} -ne 0 ]; then - echo "this script must be run as root" 1>&2 + echo "error: this script must be run as root" 1>&2 exit 1 fi echo "warning: this script will disable ssh password authentication" -echo -n "contine? [y/N] " -read answer +read -p "continue? [y/N] " answer if [ "${answer}" != "y" ]; then exit 0 @@ -34,7 +33,7 @@ if [ -f /etc/ssh/sshd_config ]; then mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak fi -cat < /etc/ssh/sshd_config +cat << EOF > /etc/ssh/sshd_config Port 22 Protocol 2 HostKey /etc/ssh/ssh_host_ed25519_key @@ -66,10 +65,9 @@ Subsystem sftp /usr/lib/openssh/sftp-server UsePAM yes EOF -echo "enter your username" -read user +read -p "enter your username " user -if [ -z ${user} ]; then +if [ -z "${user}" ]; then echo "error: no user submitted" 1>&2 mv /etc/ssh/sshd_config.bak /etc/ssh/sshd_config exit 1 @@ -81,10 +79,9 @@ fi chmod 700 /home/${user}/.ssh chown ${user}: /home/${user}/.ssh -echo "paste your ssh public key" -read sshkey +read -p "paste your ssh public key " sshkey -if [ -z ${sshkey} ]; then +if [ -z "${sshkey}" ]; then echo "error: no ssh key submitted" 1>&2 mv /etc/ssh/sshd_config.bak /etc/ssh/sshd_config exit 1 @@ -95,3 +92,10 @@ chmod 600 /home/${user}/.ssh/authorized_keys chown ${user}:root /home/${user}/.ssh/authorized_keys service ssh restart + +ssh=$(ps aux | awk '/\/usr\/s?bin\/sshd/') +if [ -z "${ssh}" ]; then + echo "error: ssh service failed to restart" 1>&2 + echo "please check for sshd config errors manually" 1>&2 + exit 1 +fi