Skip to main content

SSH and Git

Chapter 27: Setting Up Git Over SSH

In this chapter, you'll learn how to use Git securely over SSH with GitHub, GitLab, and Bitbucket, generate and configure SSH keys, switch repositories from HTTPS to SSH, and understand how deploy keys work for automation and CI/CD systems.

In the previous chapter, you learned how to set up a chroot jail SFTP server that keeps users locked inside a specific directory, prevents shell access, hides the rest of the filesystem, and stops them from running system commands.

Now it’s time to learn something every Linux user, developer, and DevOps engineer works with every day: Git repositories and SSH authentication.

You may already use GitHub or GitLab to push and pull code, but have you ever wondered what actually happens:

  • When Git connect using SSH?
  • What are SSH keys?
  • Why do deploy keys exist?
  • When should you use deploy keys instead of personal SSH keys?
  • And how can you manage multiple Git accounts without key conflicts?

In this chapter, you will learn all of these concepts step by step in a beginner-friendly way.

By the end, you will know how to use Git securely over SSH with platforms like GitHub and GitLab, manage different SSH keys properly, and configure multiple Git accounts without confusion.

Why Git Uses SSH