add ssh key to linux server code example
Example 1: how to generate ssh key in linux
ssh-keygen -t rsa -b 4096
ssh-keygen -t dsa
ssh-keygen -t ecdsa -b 521
ssh-keygen -t ed25519
Example 2: add public key to server
ssh-copy-id -i ~/.ssh/mykey.pub user@host
Example 3: add ssh key linux
$ ssh-keygen -t ed25519 -C "[email protected]"
Example 4: setting up the ssh keys
scp $HOME/.ssh/id_rsa.pub [email protected]:~/.ssh/authorized_keys
Example 5: insert key file ssh linux
sudo chmod 400 [key file]
sudo ssh -i [key file] [username]@[ip]