I just bought a Raspberry Pi 3 model b, and I love it. I use it only headless through a SSH connection which ask me for my account password (my default account name is still pi). But since I change something in the sshd_config file, I no longer need to enter my account password to connect. And I can't figure what I messed up ...

Thanks in advance.


  • 1
    Did you set up passwordless logins for SSH? This is not a mistake it actually improves security of SSH connections. You are going to show us your sshd_config file (remove anything sensitive) for us to be able to help you. Jul 19 '17 at 21:17
  • Indeed I use a passwordless login for SSH since I read it was much more secure. Still, am I not supposed to used the password of my pi account ? Or I guess that's the point of using a rsa key ... I don't quiet understand everything yet.
    – Lou
    Jul 19 '17 at 21:31
  • 1
    passswordless logins use the key pair in place of the password. Jul 19 '17 at 21:38
  • So it means back then I did not use a key pair to connect through SSH ?
    – Lou
    Jul 19 '17 at 21:42
  • 2
    correct you need to enable and copy your private key to the machine you are logging into before passwordless logins will work. The default install of raspbian uses passwords. This series of blog posts about SSH I wrote for our blog may help raspberrypise.tumblr.com/post/148032481829/… Jul 19 '17 at 21:48

If you can no longer access your machine over SSH using your account password than you likely set the following configuration to 'no' in your /etc/ssh/sshd_config file:

# Change to no to disable tunnelled clear text passwords
PasswordAuthentication yes

Once you do this than SSH will only authenticate using a public/private keypair. To enable authentication by username/password again just change this setting back to "yes" (as seen above) and either restart the SSH daemon or restart your pi.

In case you were trying to disable password authentication and move to public key authentication here are the basic steps to make it work:

1). Generate a public/private keypair using openssh (the exact utility is ssh-keygen). This will result in the creation of two files; the public key will end with .pub and the private key should not have any extension. If you accept the default names for these files than "id_rsa" is your private key and "id_rsa.pub" is your public key.

2). Next you need to access your raspberry pi and open the /home/<user>/.ssh/authorized_keys file in a text editor (if no such file exists than create one). Take the entire content of your public key and paste it into this file so that the key is all on a single line. Note that you want everything from the 'ssh-xxx' prefix on the line all the way to the comment at the end (typically something like an email) if you provided one.

3). Next you need to chmod the authorized_keys file so that it is only readable to your user. OpenSSH will generally not trust files that can be opened and modified by any other users on the system.

4). Now you can establish a connection from any machine where your private key exists to the raspberry pi. To do this from command line just provide the -i option and supply the path to your private key. Example: ssh -i /home/fooguy/.ssh/id_rsa fooguy@

The salient point regarding the keys is this:

1). The private key must be on the machine you will be initiating the SSH connection FROM.

2). The public key must be on the machine you are connecting TO (specifically in the .ssh/authorized_keys file of the user you are attempting to connect as).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.