$ ssh-keygen -t ed25519 -C "[email protected]"
ssh-keygen -t ed25519 -C "[email protected]"
ssh-keygen -t ed25519 -C "[email protected]"
ssh-copy-id username@your_server_ip
ssh-copy-id username@your_server_ip
ssh-copy-id username@your_server_ip
cat ~/.ssh/id_ed25519.pub
cat ~/.ssh/id_ed25519.pub
cat ~/.ssh/id_ed25519.pub
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "PASTE_YOUR_PUBLIC_KEY_HERE" >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "PASTE_YOUR_PUBLIC_KEY_HERE" >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "PASTE_YOUR_PUBLIC_KEY_HERE" >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
ssh username@your_server_ip
ssh username@your_server_ip
ssh username@your_server_ip
-weight: 600;">sudo nano /etc/ssh/sshd_config
-weight: 600;">sudo nano /etc/ssh/sshd_config
-weight: 600;">sudo nano /etc/ssh/sshd_config
PasswordAuthentication no
PasswordAuthentication no
PasswordAuthentication no
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart sshd
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart sshd
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart sshd
-weight: 600;">sudo -weight: 500;">service ssh -weight: 500;">restart
-weight: 600;">sudo -weight: 500;">service ssh -weight: 500;">restart
-weight: 600;">sudo -weight: 500;">service ssh -weight: 500;">restart
-weight: 600;">sudo nano /etc/ssh/sshd_config
-weight: 600;">sudo nano /etc/ssh/sshd_config
-weight: 600;">sudo nano /etc/ssh/sshd_config
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart sshd
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart sshd
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart sshd
ssh -p 2222 username@your_server_ip
ssh -p 2222 username@your_server_ip
ssh -p 2222 username@your_server_ip
PermitRootLogin no
PermitRootLogin no
PermitRootLogin no
AllowUsers user1 user2
AllowUsers user1 user2
AllowUsers user1 user2
AllowGroups sshusers
AllowGroups sshusers
AllowGroups sshusers
# For Debian/Ubuntu
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install fail2ban # For CentOS/RHEL
-weight: 600;">sudo -weight: 500;">yum -weight: 500;">install epel-release
-weight: 600;">sudo -weight: 500;">yum -weight: 500;">install fail2ban
# For Debian/Ubuntu
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install fail2ban # For CentOS/RHEL
-weight: 600;">sudo -weight: 500;">yum -weight: 500;">install epel-release
-weight: 600;">sudo -weight: 500;">yum -weight: 500;">install fail2ban
# For Debian/Ubuntu
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">update
-weight: 600;">sudo -weight: 500;">apt -weight: 500;">install fail2ban # For CentOS/RHEL
-weight: 600;">sudo -weight: 500;">yum -weight: 500;">install epel-release
-weight: 600;">sudo -weight: 500;">yum -weight: 500;">install fail2ban
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start fail2ban
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable fail2ban
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start fail2ban
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable fail2ban
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start fail2ban
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable fail2ban
-weight: 600;">sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
-weight: 600;">sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
-weight: 600;">sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
[sshd]
enabled = true
port = ssh
# Replace 'ssh' with your custom SSH port if you changed it
# port = 2222
filter = sshd
logpath = %(sshd_log)s
maxretry = 3
bantime = 1h
findtime = 10m
[sshd]
enabled = true
port = ssh
# Replace 'ssh' with your custom SSH port if you changed it
# port = 2222
filter = sshd
logpath = %(sshd_log)s
maxretry = 3
bantime = 1h
findtime = 10m
[sshd]
enabled = true
port = ssh
# Replace 'ssh' with your custom SSH port if you changed it
# port = 2222
filter = sshd
logpath = %(sshd_log)s
maxretry = 3
bantime = 1h
findtime = 10m
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart fail2ban
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart fail2ban
-weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart fail2ban
-weight: 600;">sudo fail2ban-client -weight: 500;">status
-weight: 600;">sudo fail2ban-client -weight: 500;">status sshd
-weight: 600;">sudo fail2ban-client -weight: 500;">status
-weight: 600;">sudo fail2ban-client -weight: 500;">status sshd
-weight: 600;">sudo fail2ban-client -weight: 500;">status
-weight: 600;">sudo fail2ban-client -weight: 500;">status sshd - ssh-keygen: This is the command to generate SSH keys.
- -t ed25519: This specifies the type of encryption. Ed25519 is a modern, secure, and fast algorithm.
- -C "[email protected]": This adds a comment to your public key, which is helpful for identifying it later, especially if you manage keys for multiple servers or users. Replace "[email protected]" with your actual email address. - Enter a file in which to save the key: Press Enter to accept the default location (usually ~/.ssh/id_ed25519). If you already have a key, you might want to specify a different name to avoid overwriting it.
- Enter passphrase (empty for no passphrase): This is crucial. A passphrase acts like a password for your private key. Even if someone gets your private key file, they can't use it without the passphrase. It's highly recommended to use a strong passphrase. You'll be asked to enter it twice. - enabled = true: Activates the SSH jail.
- port: Specifies the SSH port.
- maxretry: The number of failed attempts before an IP is banned.
- bantime: How long an IP is banned (e.g., 1h for one hour).
- findtime: The time window within which maxretry must occur for an IP to be banned.