Skip to content

Commit 27dc770

Browse files
authored
Update LogIn with VSCode.md
1 parent 14938e7 commit 27dc770

1 file changed

Lines changed: 146 additions & 38 deletions

File tree

LogIn with VSCode.md

Lines changed: 146 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,24 @@ It will ask for **Username** and **Password**:
308308
---
309309
---
310310

311-
# *Back to Normal*
311+
<img src="https://user-images.githubusercontent.com/73097560/115834477-dbab4500-a447-11eb-908a-139a6edaec5c.gif">
312+
313+
</br>
314+
</br>
315+
<div style="display: flex; align-items: center; gap: 10px;" align="center">
316+
317+
---
318+
319+
# Back to Normal
320+
321+
---
322+
323+
</div>
324+
325+
</br>
326+
</br>
327+
328+
<img src="https://user-images.githubusercontent.com/73097560/115834477-dbab4500-a447-11eb-908a-139a6edaec5c.gif">
312329

313330
## for Linux
314331

@@ -403,95 +420,186 @@ git config user.email "your_email@example.com"
403420

404421
✅ After this, your computer will only use **`akashdip2001` GitHub account everywhere**.
405422

423+
---
406424
---
407425

408-
## for Windows
409-
410-
If You're on **Windows PowerShell**, so a few Linux-style commands (`ls -al`, `rm`, `nano`) won’t work the same way. Let’s fix this step by step:
426+
<img src="https://user-images.githubusercontent.com/73097560/115834477-dbab4500-a447-11eb-908a-139a6edaec5c.gif">
411427

412-
---
428+
## for Windows
413429

414-
## 🔹 1. List files in `.ssh`
430+
Opened an **Administrator CMD**, here’s a complete, copy-pasteable Windows workflow (commands + what they do) to make this machine use **only your `akashdip2001` GitHub account** with the single SSH key you already have (`id_rsa_akashdip`). Follow the steps in order.
415431

416-
Instead of `ls -al`, use:
432+
# 1) Quick check: list your `~/.ssh` folder
417433

418-
```powershell
419-
Get-ChildItem -Force $env:USERPROFILE\.ssh
434+
```cmd
435+
dir "%USERPROFILE%\.ssh" /A
420436
```
421437

422-
That will show you all files in `C:\Users\akash\.ssh`.
438+
<img width="100%" alt="Screenshot (815)" src="https://github.com/user-attachments/assets/eb3689ba-50ab-418c-a853-6e7bd4bb3c9f" />
439+
440+
The folder contains `id_rsa_akashdip` and `id_rsa_akashdip.pub`.
423441

424442
---
425443

426-
## 🔹 2. Delete old keys
444+
# 2) Ensure Git uses your account (global config)
427445

428-
If you see files like `id_rsa_work` or `id_rsa_personal`, delete them with:
446+
(You already set these; running again is harmless.)
429447

430-
```powershell
431-
Remove-Item $env:USERPROFILE\.ssh\id_rsa_work*
432-
Remove-Item $env:USERPROFILE\.ssh\id_rsa_personal*
448+
```cmd
449+
git config --global user.name "akashdip2001"
450+
git config --global user.email "akashdip.mahapatra.21@aot.edu.in"
433451
```
434452

435-
(Use `*` to also remove `.pub` versions.)
436-
437453
---
438454

439-
## 🔹 3. Create/Edit `config`
455+
# 3) Create / edit SSH config (so ssh uses this key for github.com)
440456

441-
Since `nano` doesn’t exist on Windows, use **Notepad**:
457+
This puts the right identity in the SSH client config so GitHub always gets your `id_rsa_akashdip` key.
442458

443-
```powershell
444-
notepad $env:USERPROFILE\.ssh\config
459+
```cmd
460+
notepad "%USERPROFILE%\.ssh\config"
445461
```
446462

447-
Add this inside (replace with the actual key you want to keep, e.g. `id_ed25519` or `id_rsa`):
463+
In Notepad, paste exactly (then Save → Close):
448464

449465
```
450466
Host github.com
451467
HostName github.com
452468
User git
453-
IdentityFile C:/Users/akash/.ssh/id_ed25519
469+
IdentityFile C:/Users/akash/.ssh/id_rsa_akashdip
470+
IdentitiesOnly yes
454471
```
455472

456-
Save and close.
473+
(Using forward slashes for the path is fine for OpenSSH on Windows.)
474+
475+
<img width="100%" alt="Screenshot (816)" src="https://github.com/user-attachments/assets/a1a8e4d8-168f-4221-b916-a1d76e6f2936" />
457476

458477
---
459478

460-
## 🔹 4. Start SSH agent & add your key
479+
# 4) Make sure the ssh-agent service will run and start it (you are admin so these work)
461480

462-
Run:
481+
```cmd
482+
sc config ssh-agent start=auto
483+
sc start ssh-agent
484+
```
463485

464-
```powershell
465-
Start-Service ssh-agent
466-
ssh-add $env:USERPROFILE\.ssh\id_ed25519
486+
If `sc start` says it’s already running, that’s fine.
487+
488+
---
489+
490+
# 5) Add your private key to the agent
491+
492+
```cmd
493+
ssh-add "%USERPROFILE%\.ssh\id_rsa_akashdip"
467494
```
468495

469-
*(replace `id_ed25519` with your real key file name)*
496+
* If the key has a passphrase you’ll be prompted for it.
497+
* To see what keys the agent currently has: `ssh-add -l`
470498

471499
---
472500

473-
## 🔹 5. Test GitHub connection
501+
# 6) (Optional) Fix file permissions on your private key (keeps key private)
474502

475-
```powershell
503+
```cmd
504+
icacls "%USERPROFILE%\.ssh\id_rsa_akashdip" /inheritance:r
505+
icacls "%USERPROFILE%\.ssh\id_rsa_akashdip" /grant:r "%USERNAME%:R"
506+
```
507+
508+
This removes inherited ACLs and grants you read access only.
509+
510+
---
511+
512+
# 7) Add the **public** key to your GitHub account
513+
514+
Open the public key, copy all text:
515+
516+
```cmd
517+
notepad "%USERPROFILE%\.ssh\id_rsa_akashdip.pub"
518+
```
519+
520+
<img width="100%" alt="Screenshot (818)" src="https://github.com/user-attachments/assets/63acf95e-4678-4d6f-90ca-44c23c35c88f" />
521+
522+
Then in your browser:
523+
524+
<img width="100%" alt="Screenshot (817)" src="https://github.com/user-attachments/assets/6e65e447-32a3-4e07-bf7b-526023d5e138" />
525+
526+
* Go to github.com → **Settings** (click your avatar) → **SSH and GPG keys****New SSH key**
527+
* Paste the key, title it like `akashdip-laptop`, Save.
528+
529+
---
530+
531+
# 8) Test the SSH connection (verbose debug if needed)
532+
533+
First a normal test:
534+
535+
```cmd
476536
ssh -T git@github.com
477537
```
478538

479-
You should see:
539+
Expected success message:
480540

481541
```
482-
Hi akashdip2001! You've successfully authenticated...
542+
Hi akashdip2001! You've successfully authenticated, but GitHub does not provide shell access.
543+
```
544+
545+
<details>
546+
<summary style="opacity: 0.85;"><b>If it still fails ‼️</b></summary><br>
547+
548+
If it still fails, run verbose to see which key ssh is offering:
549+
550+
```cmd
551+
ssh -vT git@github.com
483552
```
484553

554+
Look for lines like:
555+
556+
* `debug1: identity file C:\\Users\\akash\\.ssh\\id_rsa_akashdip type 0`
557+
* `Offering public key: C:\\Users\\akash\\.ssh\\id_rsa_akashdip`
558+
* If it ends with `Hi akashdip2001!` you’re good. If it ends with `Permission denied (publickey)`, read troubleshooting below.
559+
485560
---
486561

487-
👉 Right now, your config is correct (`user.name` + `user.email` are set globally), but the error:
562+
# 9) Make sure your repo remotes use SSH (not HTTPS)
563+
564+
Inside any repo:
488565

566+
```cmd
567+
git remote -v
489568
```
490-
Permission denied (publickey).
569+
570+
If you see `https://github.com/...` and you prefer SSH, switch to SSH:
571+
572+
```cmd
573+
git remote set-url origin git@github.com:akashdip2001/REPO_NAME.git
491574
```
492575

493-
means GitHub doesn’t recognize the SSH key you’re using.
494-
You either need to **add the correct key to GitHub** or **generate a new one**.
576+
(replace `REPO_NAME.git` with the repo name)
577+
578+
You can make Git automatically rewrite https → ssh for all repos (optional):
579+
580+
```cmd
581+
git config --global url."git@github.com:".insteadOf "https://github.com/"
582+
```
495583

496584
---
497585

586+
# Troubleshooting checklist (if `ssh -T` still fails)
587+
588+
1. **Did you paste the public key into GitHub?** — check SSH keys page.
589+
2. **Is ssh-agent actually running and did you `ssh-add` your key?**
590+
591+
* `ssh-add -l` should list the fingerprint.
592+
3. **Is your `config` correct?** `notepad "%USERPROFILE%\.ssh\config"` — confirm `IdentityFile` path exactly matches your file name.
593+
4. **Verbose debug**: `ssh -vT git@github.com` — look for which key is being offered. If it never offers your `id_rsa_akashdip`, `IdentitiesOnly yes` + correct IdentityFile helps force it.
594+
5. **Remove old GitHub host key if host key changed**:
595+
596+
```cmd
597+
ssh-keygen -R github.com
598+
```
599+
600+
Then retry `ssh -T git@github.com` (it will add a new `known_hosts` entry).
601+
6. **Double-check the GitHub user for the key**: the `Hi <username>!` message will show the account associated with the key.
602+
603+
</details>
604+
605+
---

0 commit comments

Comments
 (0)