← Back to Chapters

Git: What is SSH?

? Git: What is SSH?

? Quick Overview

SSH (Secure Shell) is a cryptographic network protocol that allows secure communication between computers over a potentially insecure network. In Git, SSH enables safe authentication and encrypted communication with remote repositories like GitHub, GitLab, or Bitbucket.

? Key Concepts

  • Encrypted communication between client and server
  • Password-less authentication using key pairs
  • Widely used for Git operations

? Syntax & Theory

SSH works using a public-private key pair. The public key is shared with the server, while the private key remains securely on your system.

? Code Examples

? View Code Example
// Generate a new SSH key pair
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
? View Code Example
// Start the SSH agent
eval "$(ssh-agent -s)"
? View Code Example
// Add your private key to the agent
ssh-add ~/.ssh/id_rsa

? Live Output / Explanation

? View Code Example
// Test SSH connection with GitHub
ssh -T git@github.com

? Interactive Example

Toggle light and dark mode using the button above to understand how UI themes enhance readability during development.

?️ Use Cases

  • Cloning private repositories securely
  • Pushing and pulling code without passwords
  • Automated CI/CD pipelines

? Tips & Best Practices

  • Never share your private SSH key
  • Use ssh-agent for convenience
  • Rotate SSH keys periodically

? Try It Yourself

  • Create an SSH key on your machine
  • Add it to your GitHub account
  • Clone and push a repository using SSH