Generate SSH Keys

cisshsecurity
How to generate SSH Keys?

SSH Keys are a security mechanism introduced in SSH (Secure Shell).

It use asymetric criptography (a pair of keys also refered as public key and private key) to provide secure communications and authentication both of the server and client.

1 - Open an Bash shell (Linux or Mac). If working on Windows, open the GitBash console.

2 - Type the following command adapting the sample with your email:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

1 - When asked where to store the keys, press intro to accept default file (or choose a nama for it if you like a different one).

2 - When asked for a passphase, choose a passphase to protect it.

3 - Default location for keys in Linux or Mac is inside the folder: ~/.ssh/.

4 - Default location in Windows is the folder %USERPROFILE%/.ssh/.

5 - To configure a web site to push code like Github, Bitbucket or Azure Devops, you need to open the file containing the public key (with extension .pub) and add it to the website under your account settings. It will have the following form:

ssh-rsa AAAAB3Nza...Yr3GcDWj6owKI3vhAciQQX email@machine

Copy & paste the content of the key in the target website.

To Remeber

  • It is safe to share your public key. It is like your presentation card. It identifies you.
  • Never share your private key to a third party. When doing it, you are giving the keys for others to impersonate you and commit acts on your behalf.

To known much more on SSH keys visit SSH Keys.

If you still have questions

Contact us

Let's talk?