I have connected a Raspberry Pi 2 to my laptop via network cable, and I am trying to transfer files from computer to raspi but command ssh usr@blabla.local, asks me for password and I am sure password is correct but I am getting Permission denied, please try again.

What can I do? I couldn't find a solution that fits my problem on internet.

  • How is SSH configured on the server side? Does it allow logging in with a password? Which account are you using? Copy-paste the exact command you ran and the full error messages. Oct 8 '15 at 23:28
  • ls ~/.ssh id_rsa id_rsa.pub known_hosts ssh pi@blabla.local then asks for password and says permission denied Oct 9 '15 at 13:08

If you are 100% sure that there is no mistake in your password (and no encoding issue?), could be that the user account is locked in the raspberry pi. When a user account is locked, login attempts are rejected as "Password incorrect", even if the password was correct.

Or, if you are trying to log in as root, it could also be that ssh is running with the option "no root", effectively locking the root account when coming through ssh.

EDIT/UPDATE Answering question in comment

if user account is locked, how can I fix it ?

Well... here you have basically two ways to proceed.

1. If you are in the system

NOTE: To alter anything of any other account that is not you, you need to perform the alteration as root

  • To lock an account: passwd -l <user>
  • To unlock an account: passwd -u <user>

Find more information about passwd in the manpages (man passwd)

2. If you cannot access the system (but can alter the contents of the file system)

You are talking about Raspberry Pi2, so it means that you have your system for the Raspberry somewhere in your computer and you flash it to the Raspberry Pi.

If you were talking about a general computer, you would need to proceed with a LiveCD/LiveUSB and mount the system you want to alter.

But the procedure is the same.

NOTE: Treat / as the root (/) of your target system from now on.

Assuming your target system uses shadow file, the field reserved for the password hash in /etc/passwd contains x and the hash is actually in /etc/shadow.

If this hash is preceeded by an exclamation mark (!), it means that although the account is password protected, the account is locked. Remove this exclamation mark to have again the account unlocked when you boot into the system again (in the case of Raspberry Pi or any other embedded system, you need to flash this change into the module, of course)

Find more information about shadow file format here

  • if user account is locked, how can I fix it ? Oct 9 '15 at 13:11
  • 1
    @commandos2389 I have updated my answer to include your question there Oct 9 '15 at 14:40

How did you do the network setup? @localhost would connect back to your laptop. You have to provide both interfaces with an IP within the same subnet (e.g. range - (IPv4)) and use the proper one to connect to.

(seems there was a mistake in the original question so the answer no longer fits)

  • Easier than manually assigning IPs would be to leverage a dhcp service and to connect both pi and laptop to a router. I somehow missed the localhost, you are right that this is most likely the problem here.
    – tarleb
    Oct 8 '15 at 19:09

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.