diff --git a/scripts/cloudron-support b/scripts/cloudron-support index b45d413e8..5b9e16386 100755 --- a/scripts/cloudron-support +++ b/scripts/cloudron-support @@ -77,6 +77,32 @@ if [[ "`df --output="avail" /tmp | sed -n 2p`" -lt "5120" ]]; then exit 1 fi +if [[ "${enableSSH}" == "true" ]]; then + ssh_port=$(cat /etc/ssh/sshd_config | grep "Port " | sed -e "s/.*Port //") + + ssh_user="cloudron-support" + keys_file="/home/cloudron-support/.ssh/authorized_keys" + + echo -e $LINE"SSH"$LINE >> $OUT + echo "Username: ${ssh_user}" >> $OUT + echo "Port: ${ssh_port}" >> $OUT + echo "PermitRootLogin: ${permit_root_login}" >> $OUT + echo "Key file: ${keys_file}" >> $OUT + + echo -n "Enabling ssh access for the Cloudron support team..." + mkdir -p $(dirname "${keys_file}") # .ssh does not exist sometimes + touch "${keys_file}" # required for concat to work + if ! grep -q "${CLOUDRON_SUPPORT_PUBLIC_KEY}" "${keys_file}"; then + echo -e "\n${CLOUDRON_SUPPORT_PUBLIC_KEY}" >> "${keys_file}" + chmod 600 "${keys_file}" + chown "${ssh_user}" "${keys_file}" + fi + + echo "Done" + + exit 0 +fi + echo -n "Generating Cloudron Support stats..." # clear file @@ -119,30 +145,6 @@ iptables -L &>> $OUT echo "Done" -if [[ "${enableSSH}" == "true" ]]; then - ssh_port=$(cat /etc/ssh/sshd_config | grep "Port " | sed -e "s/.*Port //") - - ssh_user="cloudron-support" - keys_file="/home/cloudron-support/.ssh/authorized_keys" - - echo -e $LINE"SSH"$LINE >> $OUT - echo "Username: ${ssh_user}" >> $OUT - echo "Port: ${ssh_port}" >> $OUT - echo "PermitRootLogin: ${permit_root_login}" >> $OUT - echo "Key file: ${keys_file}" >> $OUT - - echo -n "Enabling ssh access for the Cloudron support team..." - mkdir -p $(dirname "${keys_file}") # .ssh does not exist sometimes - touch "${keys_file}" # required for concat to work - if ! grep -q "${CLOUDRON_SUPPORT_PUBLIC_KEY}" "${keys_file}"; then - echo -e "\n${CLOUDRON_SUPPORT_PUBLIC_KEY}" >> "${keys_file}" - chmod 600 "${keys_file}" - chown "${ssh_user}" "${keys_file}" - fi - - echo "Done" -fi - echo -n "Uploading information..." paste_key=$(curl -X POST ${PASTEBIN}/documents --silent --data-binary "@$OUT" | python3 -c "import sys, json; print(json.load(sys.stdin)['key'])") echo "Done"