

If you're on a Mac, you'll find these in the ".ssh" folder inside your home directory (~./ssh/). Now, two files will have been created for you: " id_rsa.pub " (your public key) and "id_rsa" (your private key). Your identification has been saved in /Users/tobidobi/.ssh/id_rsa. $ ssh-keygen -t rsa -C public/private rsa key pair.Įnter file in which to save the key (/Users/tobidobi/.ssh/id_rsa):Įnter passphrase (empty for no passphrase): Although SSH public key authentication can be used safely without any password, you should nonetheless enter a strong passphrase to enhance security even further. Just hit RETURN to accept the default name and location. Using your email address, e.g., lets you identify it more easily later.Īfter confirming this command, you'll be asked to:

With the "-C" flag, we provide a comment which you can think of as a kind of description or label for this key. Otherwise, creating a key is just a matter of executing a single command: $ ssh-keygen -t rsa -C the "-t" flag, we demand an "RSA" type key, which is one of the newest and safest types. In this case, you can give this file to your server's administrator or (in case you're using a hosting service like GitHub or Beanstalk) upload it to your account. If a file named "id_rsa.pub" or "id_dsa.pub" is listed, you already have a key. Creating a Public Keyīefore creating a public key, you should check if you already have one: $ ls ~/.ssh When a connection via SSH is trying to be established, the server will only grant access if it has a public key installed that matches the private key of the requesting computer. Its public counterpart, in contrast, is supposed to be installed on all servers that you want to get access to. The private key (as the name implies) must be kept absolutely private to you under all circumstances. In this scenario, when it comes to authentication, you will most likely meet "SSH Public Keys".įor this type of authentication, a two-part key is used: a public and a private one. Although this is very easy to use, a lot of system administrators use the also very common "SSH" protocol for various reasons. One possibility to authenticate uses the "HTTPS" protocol which you probably already know from your browser. In these cases, some kind of authentication is necessary. Often, access to a remote Git repository on a server will be restricted: you probably don't want to allow anybody to read (or at least not write to) your files. Learn on: Desktop GUI | Command Line Language: EN | CN Authentication with SSH Public Keys
