This exercise walks through connecting your GitHub account on a remote server with SSH.\r\nObjective\r\n Connect your GitHub on your AWS EC2 instance with SSH \r\nDescription\r\n\r\n\r\nIn this exercise, you will generate an SSH key pair on a remote server (EC2 instance) and add it to your GitHub account. This will allow you to push or pull the code from a repository into your server. Then you will clone a remote repository on your EC2 instance and start the application.\r\nThen you will use the following repo to clone it on your EC2 instance and start the application.\r\n\r\n\r\nScenario\r\nGitHub is used as a remote repository for both the backend and frontend code. Our backend APIs are hosted on an EC2 instance of AWS and thus we have to move the code to the server on EC2. There are many ways to do that but GitHub serves as a great way to pull the latest code or clone a repository to the server.\r\nAnd when working with GitHub you will need to identify yourself to GitHub, this can be done using your username and password or with SSH keys. An SSH key is an alternate way to identify yourself that doesn't require you to enter your username and password every time.\r\n\r\n\r\n\r\n \r\nAcceptance criteria\r\n\r\n\r\n\r\n \tConnect and login to an EC2 instance\r\n \tGenerate an SSH key pair on an EC2 instance\r\n \tAdd the SSH key to your GitHub account\r\n \tClone the following GitHub repo and start the application\r\n\r\n\r\n\r\n \r\nHints\r\n\r\n\r\n\r\n \tUse the following command to generate an SSH key pair:\r\n\r\nssh-keygen -t ed25519 -C "email@example.com"\r\n\r\n \r\nSolution\r\n\r\n\r\nIntroduction\r\n\r\nSSH, or Secure Shell, is a protocol for securely accessing a remote computer. SSH uses encryption to protect data from being intercepted by third parties, making it an essential tool for anyone working with sensitive information. SSH also provides authentication, meaning that only authorized users can access the protected data.\r\n\r\nIn order to use SSH, you need to have a client program installed on your computer. This program will connect to a server running SSH and allow you to issue commands or transfer files. There are many different ssh clients available, so you can choose the one that best suits your needs. Once you have a client installed, using SSH is usually as simple as entering the desired command or file path into the program.\r\n\r\nThere are many different ssh clients available, each with its own unique features and functions. Some of the most popular ssh clients include PuTTY, OpenSSH, and WinSCP.\r\n\r\nYou can also use the terminal on Mac or Ubuntu for SSH.\r\n\r\n- PuTTY is an ssh client for Windows systems that is known for its small size and high level of flexibility. It offers users a variety of customization settings, including the ability to customize keyboard shortcuts and control various aspects of the terminal layout.\r\n- OpenSSH is a more robust ssh client that is commonly used on Unix-based systems. It offers advanced security features like public key authentication and allows users to easily transfer files between machines using ssh remote commands.\r\n\r\n\r\nSSH protocol allows you to connect and authenticate to remote servers and services. However, SSH protocol requires SSH keys, which is an access credential. SSH keys come in pairs, a public key that gets shared with services like GitHub, and a private key that is stored only on your computer. If these keys match, you're granted access thus allowing you to connect to GitHub without supplying your username and password every time.\r\n\r\n\r\nSolution\r\nConnect to your EC2 instance. You can do so by either using EC2 instance Connect or with an SSH client (connect to a remote server with SSH).\r\nOnce you login to your instance try cloning the following GitHub repository:\r\n\r\n\r\ngit clone firstname.lastname@example.org:url\r\n\r\n\r\nYou will be first asked to confirm if you want to connect to GitHub.\r\nPermission to connect\r\n \r\n\r\nHowever, If you enter yes, permission will be denied and you will get the following message.\r\nPermission denied\r\n\r\n\r\nThe git clone fails because GitHub requires a way to authenticate you. You can identify yourself either with your username password or with SSH keys. In this example, we will be identifying using SSH keys.\r\nGenerating SSH key pairs: The first step in using SSH authorization with GitHub is to generate your own key pair.\r\nYou might already have an SSH key pair on your machine. You can check to see if one exists by going to your .ssh directory and listing the contents with the following commands.\r\n\r\n\r\n cd ~\/.ssh\r\n\r\n ls\r\n\r\n\r\nIf you see id_rsa.pub, you already have a key pair and don't need to create a new one.\r\nIf you don't see id_rsa.pub, use the following command to generate a new key pair. Make sure to replace email@example.com with your own email address.\r\n\r\n\r\n$ ssh-keygen -t rsa -b 4096 -C "firstname.lastname@example.org"\r\n\r\n\r\nYou will then be asked to provide an optional passphrase. This can be used to make your key even more secure, but for this lesson, you can skip it by hitting enter twice.\r\nWhen the key generation is complete, you should see the following message:\r\nConfirmation message\r\n\r\n\r\n\r\n\r\n\r\nAdd your public key to GitHub\r\nWe now need to tell GitHub about your public key. Display the contents of your new public key file with cat:\r\n\r\n\r\n$ cat ~\/.ssh\/id_rsa.pub\r\n\r\n\r\nCopy the contents of the output to your clipboard.\r\nLogin to github.com and bring up your account settings by clicking the tools icon.\r\nSelect SSH Keys from the side menu, then click the Add SSH key button.\r\nFinally, hit Add key to save. Enter your GitHub password if prompted.\r\nThen test your SSH connection\r\nTry to clone the repo once again and this time it will be successful. you can use the SSH clone URL when copying a repo to your local machine.