1. The purpose of this post

I would demo how to solve this error when do ssh works in linux:

➜  .ssh ssh-copy-id -i id_rsa.pub [email protected]
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

2. Environments

  • Linux CentOS 7

3. Solution and commands

This error is caused by the misconfiguration of SSH service, it does not allow the password login, so the ssh-copy-id complains about the “permission denied(publickey,gssapi-keyex,gssapi-with-mic)”

How to solve it? Just enable the password authentication temporarily:

3.1 Open sshd_config

vi /etc/ssh/sshd_config

3.2 find the line

find this line: PasswordAuthentication no

change to: PasswordAuthentication yes

3.3 restart ssh service

service sshd restart

3.4 retry the ssh command

➜  .ssh ssh-copy-id -i id_rsa.pub [email protected]

Everything should be ok now.

3.5 disable the password authentication of SSH service

Just undo the changes in the /etc/ssh/sshd_config, then restart the SSH service again.