bug fixes and chmod 755 on brightness.sh
This commit is contained in:
parent
dcb74ae5c2
commit
601728bd75
2 changed files with 14 additions and 10 deletions
0
brightness.sh
Normal file → Executable file
0
brightness.sh
Normal file → Executable file
|
|
@ -1,13 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ ${EUID} -ne 0 ]; then
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "warning: this script will disable ssh password authentication"
|
echo "warning: this script will disable ssh password authentication"
|
||||||
echo -n "contine? [y/N] "
|
read -p "continue? [y/N] " answer
|
||||||
read answer
|
|
||||||
|
|
||||||
if [ "${answer}" != "y" ]; then
|
if [ "${answer}" != "y" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
|
|
@ -34,7 +33,7 @@ if [ -f /etc/ssh/sshd_config ]; then
|
||||||
mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
|
mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat <<EOF > /etc/ssh/sshd_config
|
cat << EOF > /etc/ssh/sshd_config
|
||||||
Port 22
|
Port 22
|
||||||
Protocol 2
|
Protocol 2
|
||||||
HostKey /etc/ssh/ssh_host_ed25519_key
|
HostKey /etc/ssh/ssh_host_ed25519_key
|
||||||
|
|
@ -66,10 +65,9 @@ Subsystem sftp /usr/lib/openssh/sftp-server
|
||||||
UsePAM yes
|
UsePAM yes
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "enter your username"
|
read -p "enter your username " user
|
||||||
read user
|
|
||||||
|
|
||||||
if [ -z ${user} ]; then
|
if [ -z "${user}" ]; then
|
||||||
echo "error: no user submitted" 1>&2
|
echo "error: no user submitted" 1>&2
|
||||||
mv /etc/ssh/sshd_config.bak /etc/ssh/sshd_config
|
mv /etc/ssh/sshd_config.bak /etc/ssh/sshd_config
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -81,10 +79,9 @@ fi
|
||||||
chmod 700 /home/${user}/.ssh
|
chmod 700 /home/${user}/.ssh
|
||||||
chown ${user}: /home/${user}/.ssh
|
chown ${user}: /home/${user}/.ssh
|
||||||
|
|
||||||
echo "paste your ssh public key"
|
read -p "paste your ssh public key " sshkey
|
||||||
read sshkey
|
|
||||||
|
|
||||||
if [ -z ${sshkey} ]; then
|
if [ -z "${sshkey}" ]; then
|
||||||
echo "error: no ssh key submitted" 1>&2
|
echo "error: no ssh key submitted" 1>&2
|
||||||
mv /etc/ssh/sshd_config.bak /etc/ssh/sshd_config
|
mv /etc/ssh/sshd_config.bak /etc/ssh/sshd_config
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -95,3 +92,10 @@ chmod 600 /home/${user}/.ssh/authorized_keys
|
||||||
chown ${user}:root /home/${user}/.ssh/authorized_keys
|
chown ${user}:root /home/${user}/.ssh/authorized_keys
|
||||||
|
|
||||||
service ssh restart
|
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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue