1. Check for existing SSH Key
ls -al ~/.ssh/id_*.pub
if there are existing keys, u can either those ans skip the next step.
if u got an output with „No such file or directory or no matches found“ that means that u do not have an SSH Key . U must generate a new one., proceed with the next step
2. Generate a new SSH Key pair
// this generates a 4096 bits SSH Key pair
ssh-keygen -t rsa -b 4096 -C "your_email@domain.com"
// Press Enter to accept the default location and name
# Output:
# Enter file in which to save the key (/home/yourusername/.ssh/id_rsa):
// Press Enter otherwise u can't startup fully automated processes
# Output:
# Enter passphrase (empty for no passphrase):
//to be sure that SSH Keey are generated
ls ~/.ssh/id_*
# Output:
# /home/yourusername/.ssh/id_rsa
# /home/yourusername/.ssh/id_rsa.pub
3. Copy the public Key
//The easy was to copy:
ssh-copy-id remote_username@server_ip_address
//The hard way to copy
cat ~/.ssh/id_rsa.pub | ssh remote_username@server_ip_address "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
4. Login in your Server using SSH Keys
ssh remote_username@server_ip_address