Connect GitHub Using SSH in Linux Terminal. Push or Pull code using Terminal.

Veröffentlicht am: 31 Mai 2025
auf dem Kanal: Coding EG
415
4

SSH (Secure Shell) provides a secure and password-less way to interact with GitHub. Instead of typing your GitHub username and password every time you push or pull from a repository, you use an SSH key pair (private + public key) to authenticate automatically and securely.

This is especially useful because GitHub no longer supports password authentication for Git operations, and SSH is one of the recommended alternatives.



XXX Steps to Connect to GitHub Using SSH on Linux. XXX

1. Check for existing SSH keys
Open the terminal and run:

ls -al ~/.ssh

This lists your existing SSH keys (if any). You're looking for files like id_rsa or id_ed25519.


2. Generate a new SSH key (if needed)
If you don’t have one, create it with:

ssh-keygen -t ed25519 -C "your_email@example.com"

If ed25519 isn't supported on your system:

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

When prompted, press Enter to accept the default file location.

You can set a passphrase or leave it empty.



3. Start the SSH agent
This background process helps manage your keys:

eval "$(ssh-agent -s)"


4. Add your SSH private key to the agent

ssh-add ~/.ssh/id_ed25519


5. Copy your SSH public key
This is the key you give to GitHub:

cat ~/.ssh/id_ed25519.pub

Copy the output manually or with a clipboard tool like xclip.


6. Add your key to GitHub

Go to https://github.com/settings/keys

Click New SSH key

Paste the public key

Give it a name (e.g., "My Linux PC") and save



7. Test the connection Run:

ssh -T git@github.com

The first time, it will ask to verify GitHub’s identity. Type yes.

If successful, you’ll see:

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


8. Use SSH when cloning or updating remotes When cloning a repo, use:

git clone git@github.com:username/repository.git

Or, if you already cloned via HTTPS and want to switch:

git remote set-url origin git@github.com:username/repository.git


Auf dieser Seite können Sie das Online-Video Connect GitHub Using SSH in Linux Terminal. Push or Pull code using Terminal. mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Coding EG 31 Mai 2025 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 415 Mal angesehen und es wurde von 4 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!