Skip to content

architxkumar/ssh-remote-server-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

SSH Remote Server Setup

A DevOps learning project built to ssh into remote VM instance on GCP

Procedure

SSH Remote Server

  1. Generate ssh public and private using the following command:
ssh-keygen -t rsa -f gcp -C architxkumardev
  1. Upload the public key in Metadata section on GCP Compute Engine Screenshot of Google Cloud Compute Engine metadata section showing added ssh keys
  2. Create a VM instance by adjusting the configuration Screenshot of Google Cloud Compute Engine VM creation configuration screen
  3. SSH by opening the terminal in the key containing directory and running the following command:
ssh -i gcp architxkumardev@34.131.97.170

Congratulations! You have just sshed into the VM Instance. The user and hostmachine name will change to the remote VM's configuration Screenshot of the Terminal with ssh to remote instance

SSH Config file

  1. Create a config file in the '.ssh' flolder with permission set to read/write only for the user
cd ~/.ssh && touch config
  1. Store the follwing configuration in the file
Host [alias-name]
    Hostname [Hostname]
    User [User]
    IdentityFile [Path to private key]
  1. SSH using the alisa name
ssh [alias-name]

Fail2ban Setup

  1. SSH into the server
  2. Install dependencies
sudo apt update
sudo apt install fail2ban -y
  1. Create Local config file
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
  1. Edit jail.local file
sudo nano /etc/fail2ban/jail.local

Scroll down to sshdsection and type in the following commands

[sshd]
enabled = true
port    = ssh
logpath = %(sshd_log)s
maxretry = 5
  1. Save and start the service
sudo systemctl start fail2ban
sudo systemctl enable fail2ban
  1. Check status
sudo fail2ban-client status

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published