2026-08-17 01:05

Status:


IBM - GSGG - Module 3 & 4 - Creating SSH Key and Token

==Generating a Token for Github Authorization

Exercise 1: Generate personal access token

Let’s first create a personal access token that you will use as a password with pushing code back to GitHub.com

  1. Open GitHub.com. In the upper-right corner of any page, click your profile photo, then click Settings.

  1. Next, select Developer settings. This option is typically available towards the bottom of the window.

  2. Navigate to Tokens (classic) under Personal access tokens.

  3. To generate an access token, click Generate a personal access token.

  4. In the Generate token page, fill in the required details and click the repo checkbox to enable access for git commands.

  5. Then, click Generate token.

  6. Your personal access token will be generated. The token is only valid for 30 days. You will need to generate a new token once the current token expires.

    REMEMBER: Make sure to copy your personal access token now. You won’t be able to see it again!

==Generating an SSH Key for authentication

Generating an SSH key

To generate an SSH key, complete the following steps:

  1. Launch a terminal. If you are using Windows, launch Git Bash.

  2. Type the following command in your terminal, replacing with the email address that is linked to your Github account. When you have typed the command, press Enter.

    1. 1

    2. ssh-keygen -t rsa -b 4096 -C "<your email address>"

    Copied!Wrap Toggled!

    A new SSH key is generated.

  3. You will be prompted to enter a directory to save the key. You can simply press Enter to accept the default location, which is an .ssh folder in the home directory. This means you will be able to locate the key in ~/.ssh/id_rsa.

  4. You will be prompted to choose a passphrase. You also have the option not to create a passphrase. To skip the passphrase, press Enter twice to confirm that the passphrase is empty.

  5. Optional: To navigate to the .ssh directory, and check the contents of the directory, run the following commands in the terminal:

    1. 1

    2. cd ~/.ssh

    Copied!Wrap Toggled!

    and then,

    1. 1

    2. ls

    Copied!Wrap Toggled!

    When you list the contents of the .ssh directory, you should see id_rsa and id_rsa.pub in the list of contents, where id_rsa is the private version of your key and id_rsa.pub is the public version of your key.

  6. You now need to add the SSH key to the ssh-agent, which helps with the authentication process. To start the ssh-agent, run the following command in the terminal:

    1. 1

    2. eval "$(ssh-agent -s)"

    Copied!Wrap Toggled!

  7. To add the key to the agent, run the following command in the terminal:

    1. 1

    2. ssh-add ~/.ssh/id_rsa

    Copied!Wrap Toggled!

  8. Please find Screenshot for reference:

    image


References