#!/bin/bash #################################################################################################### #### author: SlickStack ############################################################################ #### link: https://slickstack.io ################################################################### #### mirror: http://mirrors.slickstack.io/bash/ss-perms-ubuntu-ssh.txt ############################# #### path: /var/www/ss-perms-ubuntu-ssh ############################################################ #### destination: n/a (not a boilerplate) ########################################################## #### purpose: Resets all file and user permissions for the Ubuntu SSH daemon and keys ############## #### module version: Ubuntu 20.04 LTS ############################################################## #### sourced by: ss-perms, ss-install-ubuntu-ssh ################################################### #### bash aliases: ss perms ubuntu ssh, ss perms ssh ############################################### #################################################################################################### ## include SlickStack configuration ## source /var/www/ss-config ## include SlickStack functions ## source /var/www/ss-functions #################################################################################################### #### SS-Perms-Ubuntu-SSH: Message (Begin Script) ################################################### #################################################################################################### ## this is a simple message that announces to the shell the purpose of this bash script ## ## it will only be noticed by sudo users who manually call ss core bash scripts ## ## echo message ## echo -e "${PURPLE}Running ss-perms-ubuntu-ssh: Resets all file and user permissions for the Ubuntu SSH daemon and keys... ${NOCOLOR}" sleep "$SLEEP_MESSAGE_BEGIN" #################################################################################################### #### SS-Perms-Ubuntu-SSH: Reset Permissions (SSH) ################################################## #################################################################################################### #### SSHD daemon ## chown root:root /etc/ssh/sshd_config ## must be root:root chmod 0644 /etc/ssh/sshd_config ## 0644 Ubuntu default ### SSH keys ## mkdir /var/www/meta/.ssh chown $SUDO_USER:$SUDO_USER /var/www/meta/.ssh chmod 0775 /var/www/meta/.ssh ## should be 0775 as per Ubuntu docs touch /var/www/meta/.ssh/authorized_keys chown $SUDO_USER:$SUDO_USER /var/www/meta/.ssh/authorized_keys chmod 0664 /var/www/meta/.ssh/authorized_keys ## should be 0664 as per Ubuntu docs ## reset permissions ## chown root:root /etc/ssh/sshd_config chmod 0440 /etc/ssh/sshd_config mkdir /var/www/meta/.ssh chown $SUDO_USER:$SUDO_USER /var/www/meta/.ssh chmod 0755 /var/www/meta/.ssh ## should be 0775 as per Ubuntu docs touch /var/www/meta/.ssh/authorized_keys chown $SUDO_USER:$SUDO_USER /var/www/meta/.ssh/authorized_keys chmod 0664 /var/www/meta/.ssh/authorized_keys ## should be 0664 as per Ubuntu docs #################################################################################################### #### SS-Perms-Ubuntu-SSH: Touch Timestamp File (End Script) ######################################## #################################################################################################### ## this is a dummy timestamp file that will remember the last time this script was run ## ## it can be useful for developer reference and is sometimes used by SlickStack ## ## script timestamp ## touch /var/www/meta/.timestamp-ss-perms-ubuntu-ssh #################################################################################################### #### SlickStack: External References Used To Improve This Script (Thanks, Interwebz) ############### #################################################################################################### ## Ref: ## SS_EOF