# Still typing your GitHub password every time? It's time to stop!

###   
What is SSH?

* SSH is a networking protocol which creates a secure, encrypted tunnel between you and the server.
    
* This encrypted tunnel ensures secure access and communication over the network.
    

### Where is SSH used on Github?

* When cloning a repository, you have multiple options.
    
    * HTTPS → when you want quick and easy access without extra setup.
        
    * SSH → when you contribute often and want a secure, hassle-free experience.
        

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1740030489784/1d2059a8-04fa-4495-89a2-52cca0f4794c.jpeg align="center")

* Why use HTTPS?
    
    * Some networks, like college proxies, may block SSH.
        
    * Easier for accessing public repos for read-only access, where you will be contributing rarely.
        
    * Easier to set up for beginners
        
* Why use SSH?
    
    * SSH Keys instead of id/passwords provide better security
        
    * More convenient for repeated use, contributions
        
    * Once set up, no need to type passwords at all
        

### Personal Experience with SSH and Github

* Look, I've used HTTPS for as long as I've known coding - about five years - and I recently switched to SSH.
    
* Indeed I’m new to SSH, but the security it provides and its ease of setup and use make it totally worth using!
    
* SSH shouldn’t be just an optional feature on GitHub — you should start using it now!
    
    * Trust me you will stop using and generating GITHUB\_TOKENS every now and then after this.
        

### Setting up SSH for Github

1. Start with generating your **SSH key pair**
    
    * There will be a public key and private key generated at this step.
        
    * These keys are mathematically related and work together. You will be sharing the public key with Github, while your private key stays secret.
        
    * Use the following command to generate the SSH Keypair:  
        `ssh-keygen -t ed25519 -C` [`"your-email@example.com"`](mailto:your-email@example.com)
        
        * `ed25519` is an **encryption algorithm** used for generating SSH keys
            
        * `-C email` is optional but recommended, it adds a comment to the key so that the key can be identified if you are having multiple keys.
            
2. Find the generated public keys in the `~/.ssh/` directory.
    
    * ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1740031976509/a61c1733-3bb2-4e2a-8f61-3e1e91d04c02.png align="center")
        
        locate the files `id_ed25519` and `id_ed25519.pub`.
        
    * the `.pub` file is the public key you will be sharing with Github.
        
    * Here’s how the SSH private-public key pair looks:
        
        * ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1740032229113/1decd720-65a1-4fd1-bcd1-31ddf0b2fb9a.png align="center")
            
3. Go to [Github→settings→keys](https://github.com/settings/keys) and click on `New SSH key`
    
    * It’s safe to share the public key. In fact, it's so safe that I could post mine right here on the blog.
        
    * An attacker can only encrypt a message using the public key, but only the private key can decrypt it, making it safe to share the public key.
        
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1740032723156/45326438-b3ba-4dd4-bcf0-726cc754d259.png align="center")
    
    * When adding an SSH key, you'll see two options under 'Key type':
        
        * Authentication key → Used for creating the secure communication channel before push/pull requests
            
        * Signing key → Used to sign your commits, this creates your digital signature to verify your commit’s credibility.
            
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1740033050366/a5822c04-2541-4749-8871-0b42757c0b3d.png align="center")
    
4. Once you add this SSH key, just make sure your private key is in the default location: \``~/.ssh/id_ed25519`\`.
    
5. You are done. That’s all it takes to setup SSH with Github.
    
    * Now go ahead and clone a repository using the SSH link.
        
    * Try pushing to the repository—you won’t be asked for your ID or password anymore!
        

### But we can save the password for HTTPS too, right?

* Yes, you can use `git credential.helper`, but Git itself recommends against it for security reasons.
    
* When you use this, the &lt;id,password/token&gt; pair is stored as a plain text file protected only by file permissions, which is not safe at all.
    
    * This might make HTTPS as convenient as SSH, but it doesn’t come close in terms of security.
        

Are you still using HTTPS for GitHub? Give SSH a try and see the difference! What’s stopping you from switching?
