How to use SSH to log into Github from VS Code
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.
- Open a terminal in VS Code.
ssh-keygenin the terminal, and press the enter key.
- 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.
cat ~/.ssh/id_rsa.pubin 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.
- Go to https://github.com/settings/keys and log in to your Github account if you haven't done that yet.
- 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.