SSH
The Secure Shell Protocol (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. Its most notable applications are remote login and command-line execution.
Setup an SSH Key
Generate a key pair:
Save the key in ~/.ssh/id_rsa
Copy the Key to the Server
If you dont have ssh-copy-id
:
Deactivate Password Authentication
Open the file /etc/ssh/sshd_config
with an editor like neovim or nano and uncomment the line PasswordAuthentication no.
Restart the ssh service afterwards:
SSH Login Notifications
In this example a discord webhook with discord.sh is used but anything is possible.
Add a script which contains the following:
Dont forget to make it executable: chmod +x ssh_discord_notifications.sh
Now add the following to the /etc/pam.d/sshd
file:
Restart your ssh server and then this will now log the ip of a user when logging in with ssh.