I’ve been with HostGator for my web hosting since January 2014 when I left Dreamhost. I love them. I have a reseller account that lets me sell shared hosting (i.e., assign a cPanel instance to someone who wants their own self-supported shared hosting) or provide managed hosting services to clients through my own hosting account. They’re faster than Dreamhost was and I get more for my money with the number of domains I own/service.
One of the things I like most about controlling my own hosting account is SSH access. I perform a lot of maintenance from a command line, including backups and moving files between sites. It’s a real convenience to use key files rather than entering password each time I log in, especially considering that I use complex passwords.
In late November 2016, my SSH access to HostGator changed. I could still log in, but the SSH key files no longer allowed me to do so without authenticating each time. Since the password on this account is long and difficult to remember, this means opening my password manager (1Password) and copying the password, then pasting it into the terminal window.
I spent an hour in chat-based support with HostGator on December 6 while they actively helped me. Then, after leaving me for more than 30 minutes while he researched further, he came back and asked if I was still there. While I was responding, and in less than a minute, he decided I wasn’t there and ended the chat session. I was not very happy about this.
Fast forward to today, and I’ve grown tired again of entering passwords so I started a new chat support session. Kathryn bumped me up to Tier 2 support, and I spoke to Justin, who got me as far as he could, deciding that I should probably talk to Tier 3 support. This was after two more hours of trying. I went to close an unrelated browser window and accidentally quit Safari, abruptly disconnecting Justin and subsequently making myself feel like a jerk. It actually bothered me enough I contacted HostGator via Twitter to apologize to him.
I couldn’t spend three hours tethered to a laptop on a weekend afternoon — there’s just too much stuff to do around the house right now — so I called into their phone-based tech support and eventually got James in Tier 3 support. About an hour and a half later, we’re both obviously just Googling anything we can and getting desperate. And then we realized that one of the instructions he gave me (not specific to HostGator) referenced RSA keys, whereas their help page references DSA keys.
I tried changing the type of key generated in based on their help page, and what do you know? It worked!
So, in actuality, here’s what you should do to generate SSH keys for HostGator:
In terminal, type the following command (and note that the changes from their instructions are colored red):
ssh-keygen -t rsa
This will ask you a few questions, the defaults for which are just fine, no passcode is necessary. This will generate a key in the ~/.ssh/ directory. Now we just need to get that file up to the server.
You can do this using scp, or rsync. Below is an example of a properly formatted rsync command (port 2222, the default port for HostGator shared servers), be sure to replace username with the username intended to access the server and the IP address with the address of your server:
rsync -av -e “ssh -p 2222” ~/.ssh/id_rsa.pub firstname.lastname@example.org:.ssh/authorized_keys
Once running this command you will be prompted for your root password, as rsync creates an SSH connection to transfer the file to your server. Once the password is entered the file will be synced up to the server.
Now we want to ensure that all is well on the recipient server. SSH into your server and run the following commands:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
chown username. ~/.ssh/authorized_keys
Now to access your server you need only do the following:
The server should automatically accept your key and log you into shell as the specified user.