So normally you can leave this out unless you've changed the port on the server.ĪddKeysToAgent - To be able to use the key when connecting to servers we need to add it to the SSH Agent. Port is only needed if the SSH server is listening on another port than the default one, port 22. Because we've specified "homepage" as a custom host our client needs to know what it really should point to. Hostname is the real address used for connecting to the host. If left out you need to specify it when connecting instead.
User is what remote user you want to authenticate as when connecting to the server. Like a label and you can add as many you like, separated with a space. Host - This is what you will call your host when connecting to it over SSH, this can be anything actually but should be something that is unique for the host. There are a lot of properties here, I'll desbribe each one of them. The only thing you need to do to generate a key is to open your terminal and type this command: We will be using a real world example so the hosts will be GitLab, VPS and your LAN. In this guide we will create separate keys for three different hosts/environments. For the sake of this guide we will generate and organize one for each host. That's an increased risk of losing one or many of your keys. your laptop) it is not as important compared to storing them on many (phone, tablet, work computer and other laptops). If only storing your keys in a single place (i.e. If using the same metaphor as above you then need to change the padlocks on all lockers. It would be easy to only generate a single key and use it for all servers but if you lose the key you would put all the servers at risk. An SSH key is exactly that, but just a file on your computer, that will unlock and grant you access to different hosts. If you instead use a real key it is much safer because only those with a correct key can open the locker.
#Generate ssh for git on mac code#
Unfortunately someone can see the correct code when it's being entered or even guessed if given enough tries. If you choose a padlock with a code it's very convenient and you can access it whenever you want, even if you don't have a key. You can, and should, put a padlock on the locker to keep bad persons out of it. But a good and simple example I like is to think of the server as a locker. If you want to know more about how SSH keys work there are plenty of guides out there.
#Generate ssh for git on mac full#
Anyway this post will make you an SSH key pro and you will have full control over all your keys. Or maybe you already know about SSH keys but aren't organizing them in a good way. If you've never heard about SSH keys and are still using passwords when logging in to your remote servers you're in for a treat.