0

I was trying to copy a key id for password-less SSH access, however it seems that the password authentification is no. I am not sure how to change that.

Here is the original code:

ssh-copy-id xxxx@xxxx

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/xxxx/.ssh/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

xxxx@xxxx: Permission denied (publickey).

Falio
  • 35
  • The question seems unclear. Are you asking how to properly set up key-based authentication? Are you saying you made a mistake and locked yourself out? Are you asking how to add a key to a system that you do not administer? Or are you asking something else? Take a look at https://askubuntu.com/questions/46930/how-can-i-set-up-password-less-ssh-login for an overview. – user535733 Aug 07 '21 at 14:13
  • Thank you for the link. Yes, it is what I want to do - a password-less SSH. My problem is that it does not allow me to copy the key, and I have googled some solutions and it seems they all point towards setting the password authentification from no to yes in the cofiguration. However, I am not sure how to do that. – Falio Aug 07 '21 at 14:46

1 Answers1

0

You must briefly enable password access in order to use ssh-copy-id, then disable it again.

  • Reminder: after enabling/disabling password access, you must restart sshd so it reloads the new configuration.

Example:

server$ sudo nano /etc/ssh/sshd_config        # Enable password login
server$ sudo systemctl restart sshd.service   # Restart sshd

client$ ssh-copy-id me@123.456.789.012 # Transmit your key client$ ssh me@123.456.789.012 # Test login using key

server$ sudo nano /etc/ssh/sshd_config # Disable password login server$ sudo systemctl restart sshd.service # Restart sshd

user535733
  • 62,253
  • Hello, I managed to enter the configuration regarding the first step and changed 'Password Authentification no' to 'yes'. But what command should I type to exit the configuration and return to the normal ubuntu command window? – Falio Aug 07 '21 at 14:42
  • I see! So the '^' stands for 'Ctrl'? I did see the instructions but they were all in the form of '^X' or '^R', etc. – Falio Aug 07 '21 at 14:48
  • One example of a How To Use Nano tutorial: https://www.youtube.com/watch?v=Jf0ZJZJ8jlI. There are many Nano tutorials out there. – user535733 Aug 07 '21 at 14:52
  • Thank you! It seems I need to use 'sudo /etc/init.d/ssh restart' instead to restart the ssh, I am not sure why (I am quite new to linux). The rest of them worked perfectly, many thanks! – Falio Aug 07 '21 at 15:21