ssh add public key code example
Example 1: add public key to server
ssh-copy-id -i ~/.ssh/mykey.pub user@host
Example 2: ssh add key to authorized_keys
cat ~/.ssh/id_rsa.pub | ssh USER@HOST "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
Example 3: insert file key file ssh
sudo chmod 400 [key file]
sudo ssh -i [key file] [username]@[ip]
Example 4: setting up the ssh keys
scp $HOME/.ssh/id_rsa.pub [email protected]:~/.ssh/authorized_keys