Technology Work

Passwordless SSH and Server Alias

This is an old trick and there are tons of how-to’s over the internet. I’m posting this for my own reference but it might help some developers looking for this solution.

Okay, so here’s the problem. I have a dedicated server hosted at DigitalOcean and all it gives you is the IP address and a default password. I barely didn’t have the time to set this up but now that I did, I’m documenting it. Take note though that I’m using OS X Mavericks as my client and Ubuntu 12.04 as my server.

Passwordless SSH:

  1. Generate your secure SSH Key:
    • cd ~/.ssh
      • If you don’t have that folder yet, create it by issuing this command:
        • sudo mkdir ~/.ssh
  2. Inside your .ssh folder, type in:
    • ssh-keygen
  3. Copy the generated key into our server:
    • cat ~/.ssh/id_dsa.pub | ssh user@remotehost ‘cat >> ~/.ssh/authorized_keys’
  4. Test if okay:
  5. End.
Now, my next inconvenience would be typing the user and ip address of my server. So my next move would be to put an alias to my server.
SSH Config: 
  1. Go to your .ssh folder, I assume that this is already created (see #1 of Passwordless SSH):
    • cd ~/.ssh
  2. Create a config file:
    • mkdir config
  3. Open your config file using your favorite editor (I personally use vim):
    • vi config
  4. Write the following config:
    Host <any_name_of_your_server>
    User <server_username>
    HostName <ip_address_of_your_server>
  5. Test if okay:
    • ssh <any_name_of_your_server>
  6. End.
This should help speedup my development process. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.