A DevOps learning project built to ssh into remote VM instance on GCP
- Generate ssh public and private using the following command:
 
ssh-keygen -t rsa -f gcp -C architxkumardev- Upload the public key in Metadata section on GCP Compute Engine

 - Create a VM instance by adjusting the configuration

 - SSH by opening the terminal in the key containing directory and running the following command:
 
ssh -i gcp architxkumardev@34.131.97.170Congratulations! You have just sshed into the VM Instance.
The user and hostmachine name will change to the remote VM's configuration

- Create a config file in the '.ssh' flolder with permission set to read/write only for the user
 
cd ~/.ssh && touch config- Store the follwing configuration in the file
 
Host [alias-name]
    Hostname [Hostname]
    User [User]
    IdentityFile [Path to private key]
- SSH using the alisa name
 
ssh [alias-name]- SSH into the server
 - Install dependencies
 
sudo apt update
sudo apt install fail2ban -y- Create Local config file
 
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local- Edit 
jail.localfile 
sudo nano /etc/fail2ban/jail.localScroll down to sshdsection and type in the following commands
[sshd]
enabled = true
port    = ssh
logpath = %(sshd_log)s
maxretry = 5
- Save and start the service
 
sudo systemctl start fail2ban
sudo systemctl enable fail2ban- Check status
 
sudo fail2ban-client status