Permission denied (publickey,password) code example

Example 1: ssh error permission denied (publickey)

sudo service ssh restart

Example 2: git clone permission denied (publickey)

// Run the following command to generate a key
// Press return to keep all default options
ssh-keygen

// By default the key will be saved to ~/.ssh/id_rsa.pub
// Copy the contents of this file and save it in the following location
// Gitlab: `User Settings > SSH Keys`
// GitHub: `Settings > SSH and GPG Keys`

// To test the SSH authentication use the following command
ssh -T git@gitlab.com

Example 3: ssh error permission denied (publickey)

sudo nano /etc/ssh/sshd_config
PermitRootLogin prohibit-password to PermitRootLogin yes 
PasswordAuthentication no to PasswordAuthentication yes

Example 4: permission denied (publickey password)

cat ~/.ssh/id_rsa.pub | ssh <user>@<hostname> 'cat >> .ssh/authorized_keys && echo "Key copied"'