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:
- Generate your secure SSH Key:
- cd ~/.ssh
- If you don’t have that folder yet, create it by issuing this command:
- sudo mkdir ~/.ssh
- If you don’t have that folder yet, create it by issuing this command:
- cd ~/.ssh
- Inside your .ssh folder, type in:
- ssh-keygen
- Copy the generated key into our server:
- cat ~/.ssh/id_dsa.pub | ssh user@remotehost ‘cat >> ~/.ssh/authorized_keys’
- Test if okay:
- ssh [email protected]
- ssh [email protected]
(where x is a number)
- 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:
- Go to your .ssh folder, I assume that this is already created (see #1 of Passwordless SSH):
- cd ~/.ssh
- Create a config file:
- mkdir config
- Open your config file using your favorite editor (I personally use vim):
- vi config
- Write the following config:
Host <any_name_of_your_server>
User <server_username>
HostName <ip_address_of_your_server> - Test if okay:
- ssh <any_name_of_your_server>
- End.
This should help speedup my development process. 🙂