In order to work on a remote web server, you need to connect to it with your local computer and then send it commands via the command line.
You can connect your local computer to a remote web server securely via SSH (Secure Shell). The first step in this process is to generate an SSH key pair – a key that consists of two parts: the private key which gets created and remains on your local computer and the public key which also gets created on your local computer, but you will essentially copy/paste it into the correct location on the remote web server. These two parts of the same key pair are used to confirm your identity and permit you to work on the remote web server.
Create a New SSH Key Pair
Open your Terminal program ( Intro To Command Line On A Mac ) and enter the following command:
and then hit RETURN to generate the new RSA key pair.
Next you’ll be asked where you want to store the key pair and what you want to call it. It’s going to provide a default location in something like /Users/ed/.ssh/id_rsa. Don’t overwrite the existing id_rsa file, it could destroy your access to other secure locations.
Just create a new file name – whatever you like. Eg:
Next you’ll be asked to create a password to use this key pair. I usually leave this blank because no one else has access to my laptop and I hate having to enter my password every time I use it so I just hit RETURN again here. Once you’ve hit return, the process will complete automatically.
The commands above created a new SSH key pair: MonkeyStank (the private key portion) and MonkeyStank.pub (the public key portion) and saved them to the hidden .ssh directory in my User’s home directory on my Mac laptop.
I can confirm all of this by typing the following command:
ls -al /Users/ed/.ssh RETURN
to list out the contents of the hidden .ssh directory.
Now I want to copy the public portion of this new SSH key pair into my clipboard so that I can paste it into the correct location when I set up a new DigitalOcean server to work on. So I’ll enter the following command:
pbcopy < /Users/ed/.ssh/MonkeyStank.pub RETURN
and the public portion of the key will be copied to my clipboard.
Now I’ve got a new SSH key pair and I’m ready to set up a new Ubuntu server on DigitalOcean.