Skip to content

Instantly share code, notes, and snippets.

@ddeveloperr
Last active February 3, 2016 09:14
Show Gist options
  • Save ddeveloperr/8ff9fe041032b55d6fc9 to your computer and use it in GitHub Desktop.
Save ddeveloperr/8ff9fe041032b55d6fc9 to your computer and use it in GitHub Desktop.
SSH 101 Tutorial
SSH 101 Tutorial
An SSH key allows you to establish a secure connection between your computer and GitLab. Before generating an SSH key in your shell, check if your system already has one by running the following command:
cat ~/.ssh/id_rsa.pub
If you see a long string starting with ssh-rsa or ssh-dsa, you can skip the ssh-keygen step.
Note: It is a best practice to use a password for an SSH key, but it is not required and you can skip creating a password by pressing enter. Note that the password you choose here can't be altered or retrieved.
To generate a new SSH key, use the following command:
ssh-keygen -t rsa -C "$your_email"
This command will prompt you for a location and filename to store the key pair and for a password. When prompted for the location and filename, you can press enter to use the default.
Use the command below to show your public key:
cat ~/.ssh/id_rsa.pub
Copy-paste the key to the 'My SSH Keys' section under the 'SSH' tab in your user profile. Please copy the complete key starting with ssh- and ending with your username and host.
To copy your public key to the clipboard, use code below. Depending on your OS you'll need to use a different command:
Windows:
clip < ~/.ssh/id_rsa.pub
Mac:
pbcopy < ~/.ssh/id_rsa.pub
GNU/Linux (requires xclip):
xclip -sel clip < ~/.ssh/id_rsa.pub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment