So I've been testing this script in a digital ocean droplet just trying to perfect it before I redo my current server later this fall. There's one problem that I've found that pertains to this script especially. And it deals with SSH keys and logging on with them.
I was trying everything, and I spent hours trying to figure out the problem, reading debug logs and the like. I've no no issues using SSH keys on servers before. It's supposed to be as simple as adding your public key to an authorided_users file in the ~/.ssh folder. Then change the /etc/ssh/sshd_config file to disable root login and password based logins.
I did all of this, but I was unable to login, and I continued to get a publickey error when trying to login. I tried several other scripts on different droplets with no problem. And obviousl, my current box is working so I narrowed it down to something this scrip does that's causing me this headache. What it's doing, I have no idea. But I did figure out how to fix it and it was a permissions issue, as usual, with me and linux.
I ran these commands which fixed my problem. If anyone else has this issue, try this.
chmod o-w ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys