A common transport protocol for Git is SSH, which provides secure access to remote servers, in this case our git servers stack. This protocol consists of a SSH key pair, which includes a public key and a private key.
Step 1. Create a SSH key pair
A SSH key pair consists in a public key and a private key. You need to add the public key in the Presslabs dashboard and store carefully the private key and not share it with anyone.
1. On Linux and MacOS
In order to create a SSH key pair on Linux or macOS, you need to use the
ssh-keygen command. Simply open the terminal and run:
This command will require you to fill the next fields:
- Enter the file name where you want to save the key (
/home/<user_name>/.ssh/id_rsa) This means that if you leave this field empty and simply press ENTER, it will save the private key as
id_rsaand the public key as
- Enter passphrase (empty for no passphrase)
- Enter same passphrase again
Now, in the
.ssh directory you will have the two keys created. Unless you changed their names, the public key is
id_rsa.pub and the private one is
Display the public key in the command line so you can copy it:
An example of a public key can be seen below.
2. On Windows
Generate a SSH key pair from Git Bash
Git for Windows focuses on offering a lightweight, native set of tools that bring the full feature set of Git SCM to Windows while providing appropriate user interfaces for experienced Git users and novices alike.
It comes with a BASH emulation used to run Git from the command line, as well as a Git GUI. The installation is simple and straightforward.
This way, simply open the Git BASH command line and follow exactly the same steps as for Linux and macOS operating systems, using
Generate SSH key pair using PuTTYgen
PuTTYgen is a SSH keys generator tool for PuTTY, resembling the
ssh-keygen from linux and macOS. PuTTYgen is normally installed as part of the normal PuTTY package installation, which you can install from here.
After installing PUTTYgen, go to
Windows Start menu → All Programs → PuTTY→ PuTTYgen to start it.
In order to generate a SSH Key Pair, simply press the Generate button, then move your mouse in order to generate some randomness.
You need to save your private key and store it in the
/home/<user_name>/.ssh/ directory, along with your public key. You need to copy the public key shown here, and introduce it in the Presslabs dashboard as shown at Step 2.
Step 2. Add your public key to our dashboard
You need to upload the public key in our
Dashboard in the
SSH Keys Section. The private key needs to be stored and handled carefully, and no copies of the private key should be distributed.
Go to https://o.presslabs.com/#/account/ssh-keys, as seen below.
Here you need to fill in the blanks:
- Label: set a label for your key
- Public Key: paste the public key copied from the terminal.
Step 3. Clone your code locally
Now you can clone your code locally. The clone URL can be found in the Access section in the dashboard:
git clone firstname.lastname@example.org:user/mysite.git cd mysite git checkout master
Can I use ssh-keygen on windows?
Yes, you can generate a SSH key pair on Windows operating systems using ssh-keygen if you install Git for Windows, check Generate a SSH key pair from Git Bash.