Skip to main content
How to Connect to GitHub or a Web Server Securely with SSH

How to Connect to GitHub or a Web Server Securely with SSH

Watch full video at:

Introduction:
Connecting to GitHub or a web server requires a secure method to protect your sensitive data. While password authentication is a common approach, it can be easily compromised if the password is weak or guessable. In this blog post, we’ll explore a more secure way to connect using SSH (Secure Shell).

But for some reason, if you choose to stick with password then I would recommend that you use something like 1Password which helps you create and manage your password in a more secure way.

The Importance of Security:
When it comes to the security of your GitHub page or web server, it’s crucial to prioritize strong authentication methods. While password-based authentication is relatively convenient, it may not provide sufficient protection against unauthorized access. To enhance security, it’s highly recommended to use SSH.

Understanding Encryption:
Before we delve into SSH, it’s essential to understand encryption. Encryption algorithms like MD5, SHA-1, and SHA-256 can encrypt input data. However, if the encryption algorithm is known, it becomes easier for attackers to decrypt the data. To strengthen encryption, it is advisable to combine an encryption algorithm with a randomly generated salt. This combination significantly increases the difficulty of decryption, especially when the algorithm and random string remain undisclosed.

Generating SSH Keys:
To establish an SSH connection, you need to generate SSH keys. Follow these steps:

  1. Open your terminal and navigate to the SSH folder by running the following command: cd ~/.ssh
  2. Generate the public and private keys using the command: ssh-keygen

This command will generate the public and private key files.

Configuring SSH:
To instruct SSH to use your private key for every connection attempt, you need to modify the SSH config file. Here’s how:

  1. Open the SSH config file using a text editor: vi ~/.ssh/config
  2. Add the following content to the config file: Host * AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/kirandash_github

Adding Key to Apple Keychain:
To streamline the SSH authentication process, you can add the private key to Apple Keychain. Follow these steps:

  1. Run the command: `ssh-add -K kirandash_github

This command adds the private key to the Apple Keychain.

Configuring GitHub To establish a connection with your GitHub account, you need to add the public key. Here’s how:

  1. Display the contents of the public key by running the command: cat kirandash_github.pub
  2. Copy the public key.
  3. Go to your GitHub account settings and find the SSH key settings page.
  4. Add the copied public key to the list of authorized keys.

Conclusion:
By following these steps, you can connect to GitHub or a web server securely using SSH. SSH provides a stronger authentication mechanism compared to password-based authentication, enhancing the overall security of your system. Implementing these measures will help protect your data and ensure a safer connection to your remote servers.

Remember, prioritizing security is crucial in today’s digital landscape, and SSH is an essential tool in achieving that goal.