How to use SSH to log into Github from VS Code

·

2 min read

Before August 13, 2021, you can simply use a Github username and password in VS Code terminal to log into Github. But now that's no longer possible. We can use either SSH or personal access token to log into Github from VS Code.

I will introduce the easier way - SSH, in this post.

Steps:

  1. Open a terminal in VS Code.
  2. Enter ssh-keygen in the terminal, and press the enter key.
  3. There will be prompted for a “passphrase” (i.e., password). If you decide to not set a password, just press the enter key. Otherwise, input a password (no need to be the same as your Github password), then press the enter key, then input the password again, then press the enter key.
  4. Enter cat ~/.ssh/id_rsa.pub in the terminal, and press the enter key. Your "public key" will be shown in the terminal. Copy the public key, from "ssh-rsa" to the end.
  5. Go to https://github.com/settings/keys and log in to your Github account if you haven't done that yet.
  6. Click New SSH key . Paste your copied public key into the text box under Key. You can also optionally input a title under Title, like "my laptop". Then click Add SSH key.

Now you are all set to log into Github from your VS Code. If you input a password in step 3, you might be asked to enter that.