SSH keys are specialized text files that allow you to establish secure connections between different computers.
In this case, you need an SSH key in order to securely connect to the Laravel Homestead virtual machine. Here’s how you can create one.
Check to see if you already have one
In the command line — Terminal on a Mac, Git Bash in Windows — run the following command:
$ ls -1 ~/.ssh
If you see a list of files, including one named id_rsa.pub
, then you’re all set! You have an SSH key already.
If you do not see id_rsa.pub
, or if you get an error message like: No such file or directory
, continue on — you need to generate a new SSH key.
Generate a new SSH key
To create the key file, in the command line, run:
$ ssh-keygen -t rsa -C "<your_email_address>"
…substituting your actual email address for <your_email_address>
.
When it asks you what path/destination you want to create the key at, just hit ENTER — that will install it in the default location, which is what you want.
In this case, you don’t need to enter a passphrase — so just hit ENTER for both the passphrase & passphrase-confirmation questions, which will leave it blank (i.e. no passphrase).
Register the key
Then, to register the key (i.e. make your computer aware it exists), run the following two commands:
eval `ssh-agent -s`
ssh-add ~/.ssh/id_rsa
Check for the new key
Re-run the original command:
$ ls -1 ~/.ssh
…and you should now see id_rsa.pub
listed.
You’re good to go!