This document outlines the steps taken to set up an SSH key pair, configure SSH authentication, set up Nginx, and link the SSH key with GitHub.
- Generated SSH key
- Added public key to server
- Configured SSH access / updated the config file
- SSH Alias setup
- Set up Nginx web page
- Added SSH key to GitHub
- Configuring Git on the Server
- Authenticated with GitHub
- Cloned Git Repository
Created an SSH key pair using the command:
ssh-keygen -t ~/.ssh/demo_ed25519 -C "DA live call demo key"- Used ssh-copy-id to add the public key to the remote server for passwordless login:
ssh-copy-id username@host- Test ssh connection before disabling password-based login
ssh servername@host- Updated the SSH server configuration file to allow login only via SSH key, disabling password-based login:
/etc/ssh/sshd_config-
In the config file changed the "PasswordAuthentication" to "no"
-
Restarted the SSH service to apply the changes:
sudo systemctl restart sshd- Successfully logged in to the server using the SSH key (passwordless login).
- Created an SSH alias to avoid using the full path to the SSH key every time:
alias dal_connect="ssh -o StrictHostKeyChecking=False -i ~/Users/macUserName/.ssh/id_ed25519 username@host"- Checking if the alias is existing
alias | grep dal- Testing that a login with alias is working:
dal_connect- Installed NGINX package and set up a basic webpage:
sudo apt install nginx -y- Created a custom Nginx page by editing the default HTML content
sudo mkdir var/www/alternatives
sudo touch /var/www/alternatives/alternate-index.html- Updated the page content in the configuration:
sudo nano /etc/nginx/sites-enabled/alternatives-
Added server blocks with port 8081 and html
-
Ensured the Nginx service was running:
sudo service nginx restart- Opening the NGINX webpage using the IP address
- Adding a port 8081 to see the changed HTML page after updating the configuration:
localhost:8081- Added the public SSH key to GitHub to authenticate Git operations from the server under "Settings > SSH and GPG Keys".
- Retrieved the public key using:
cat ~/.ssh/id_ed25519.pubConfigured Git on the server to use the same username and email as on GitHub for consistency:
git config --global user.name "GitHub Name"
git config --global user.email "my-email@example.com"Verified SSH authentication with GitHub by running:
ssh -T git@github.com git clone git@github.com:Bodev13/v-server-setup.gitAdd new test text