change the ssh user detection to rely on SUDO_USER

This commit is contained in:
Johannes Zellner
2018-11-08 19:39:18 +01:00
parent 9fe91cf9cb
commit d2182559e8

View File

@@ -17,13 +17,13 @@ echo -n "Generating Cloudron Support stats..."
rm -rf $OUT
ssh_port=$(cat /etc/ssh/sshd_config | grep "Port " | sed -e "s/.*Port //")
if [[ `cat /etc/ssh/sshd_config | grep PermitRootLogin | grep yes` ]]; then
if [[ $SUDO_USER === "" ]]; then
ssh_user="root"
ssh_folder="/root/.ssh/"
authorized_key_file="${ssh_folder}/authorized_keys"
else
ssh_user="ubuntu"
ssh_folder="/home/ubuntu/.ssh/"
ssh_user="$SUDO_USER"
ssh_folder="/home/$SUDO_USER/.ssh/"
authorized_key_file="${ssh_folder}/authorized_keys"
fi