Step 1 Setup Git

Add GitHub or Bitbucket SSH (Mac + Windows)


GitHub (SSH Setup)

🔁 Find & Replace (according to your need)

  • Email: youremail@example.com
  • Key name: id_rdgh
  • Host alias: rdgh.github.com

    Here, rdgh is the shorthand which you will need if you want to set up multiple accounts.

🔑 Generate and Add SSH Key

Reference:
https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

If GitHub Desktop is installed, you can clone repositories without SSH keys.


đŸĒŸ Windows (PowerShell – Admin)

Get-Service -Name ssh-agent | Set-Service -StartupType Manual
Start-Service ssh-agent

Add key (non-admin terminal):

ssh-add "C:\Users\Rana Depto\.ssh\id_rdgh"

🍎 macOS / Linux

cd ~/.ssh
ssh-keygen -t ed25519 -C youremail@example.com

Legacy systems:

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

File name when prompted:

id_rdgh

Passphrase: Leave empty (press Enter twice).


â–ļī¸ Start ssh-agent (if needed)

eval "$(ssh-agent -s)"

âš™ī¸ SSH Config File

Edit config:

code ~/.ssh/config

Windows path

C:\Users\Rana Depto\.ssh\config

Add:

Host rdgh.github.com
  HostName github.com
  AddKeysToAgent yes
  IdentityFile C:\Users\Rana Depto\.ssh\id_rdgh

If error appears:

Host github.com
  IgnoreUnknown UseKeychain

➕ Add Key to Agent

macOS

ssh-add --apple-use-keychain ~/.ssh/id_rdgh.pub

Windows

ssh-add "C:\Users\Rana Depto\.ssh\id_rdgh"

🌐 Add SSH Key to GitHub

Login: https://github.com/login

SSH Keys Page: https://github.com/settings/keys

Copy key:

code id_rdgh.pub

Add Title and Key


✅ Test Connection

ssh -T git@rdgh.github.com

Expected:

Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access.

🔄 Reset SSH Cache (If Needed)

ssh-add -D
ssh-add ~/.ssh/id_rdgh
ssh-add -ld

đŸ“Ļ Clone Examples

git clone git@github.com:researchacademy/test.git
git clone git@github.com:ranadepto/CyberSecurity.git

Bitbucket (SSH Setup)

🔁 Find & Replace

  • Email: youremail@example.com
  • Key name: id_rdbb
  • Host alias: rdbb.bitbucket.org

🔑 Generate SSH Key

Reference: https://support.atlassian.com/bitbucket-cloud/docs/set-up-personal-ssh-keys-on-macos/

cd ~/.ssh
ssh-keygen -t ed25519 -C youremail@example.com

File name

id_rdbb

➕ Add Key to Agent

macOS

ssh-add --apple-use-keychain ~/.ssh/id_rdbb.pub

Windows

ssh-add "C:\Users\Rana Depto\.ssh\id_rdbb"

âš™ī¸ SSH Config

code ~/.ssh/config

Add:

Host rdbb.bitbucket.org
  HostName bitbucket.org
  AddKeysToAgent yes
  IdentityFile ~/.ssh/id_rdbb

🌐 Add SSH Key to Bitbucket

https://bitbucket.org/account/settings/ssh-keys/

Copy key:

macOS

pbcopy < ~/.ssh/id_rdbb.pub

Windows

code id_rdbb.pub

Add key with a meaningful label.


✅ Test Connection

ssh -T git@rdbb.bitbucket.org

Expected:

authenticated via ssh key.
You can use git to connect to Bitbucket. Shell access is disabled

đŸ“Ļ Clone Example

git clone git@rdbb.bitbucket.org:ranadepto/WebFrontend.git

â„šī¸ Notes

  • Public keys must end with .pub
  • If SSH key is invalid, ensure the entire key is copied
  • Multiple accounts supported using SSH host aliases
0%