How to fix ssh-copy-id permission denied?

0696

If you're encountering a "permission denied" error when using ssh-copy-id, here are some steps to troubleshoot and fix the issue:

  1. Check SSH Key Permissions:
    Ensure that your SSH keys have the correct permissions. Run the following commands to set the appropriate permissions:

    chmod 700 ~/.ssh
    chmod 600 ~/.ssh/id_rsa
    chmod 644 ~/.ssh/id_rsa.pub
  2. Verify SSH Service:
    Make sure the SSH service is running on the remote server. You can check this with:

    sudo systemctl status ssh

    If it's not running, start it with:

    sudo systemctl start ssh
  3. Check User and Host:
    Ensure you are using the correct username and hostname in your ssh-copy-id command. The syntax is:

    ssh-copy-id user@hostname
  4. Firewall Settings:
    Check if a firewall is blocking SSH connections. You may need to allow SSH through the firewall:

    sudo ufw allow ssh
  5. SSH Configuration:
    Review your SSH configuration file (/etc/ssh/sshd_config) on the remote server. Ensure that PermitRootLogin is set to yes if you're trying to log in as root, and that PasswordAuthentication is enabled.

  6. Test SSH Connection:
    Before using ssh-copy-id, test your SSH connection manually:

    ssh user@hostname

    If you can connect, then try ssh-copy-id again.

If you continue to face issues, please provide more details about the error message for further assistance!

0 Comments

no data
Be the first to share your comment!