I'm trying to access my RPi 3 via Putty from a Windows 10 laptop. When it prompts me to choose the user I type in pi. I have tried typing in raspberry as the password, resetting the password with sudo passwd and trying with that password but nothing works. BTW I have already placed a file named ssh in the boot partition of my Pi so that it automatically boots with ssh on. I'm using NOOBS 2.1.0.
-
1Have you checked if your keyboard layout match when using Putty. Try writting the password instead of loggin, does it match?– jlandercyCommented Jun 23, 2017 at 16:39
-
@jlandercy Yeah, It matches– IliyanCommented Jun 23, 2017 at 17:23
-
Using sudo passwd changes the root password. I don't remember if root logins via SSH are off by default, but I think they are. You should not permit root logins as a security measure.– Steve RobillardCommented Jun 23, 2017 at 17:24
-
@SteveRobillard Ok, so since it changes the root password, I tried logging in with root@IP, but even then when writing the password it gives me the error.– IliyanCommented Jun 23, 2017 at 17:29
3 Answers
Is this your first time trying to SSH into the Raspberry Pi? I did this a couple of days ago, and manually changed the Pi's configuration from the GUI interface to allow for SSHing, then rebooted.
In case you haven't seen it, here's the official documentation https://www.raspberrypi.org/documentation/remote-access/ssh/
-
1st: No, this isn't the last time I use SSH with my Pi, but the last time was quite long ago. 2nd: Yes, I did all of that, nothing seems to work.– IliyanCommented Jun 23, 2017 at 16:27
-
Have you tried resetting your ssh keys with ssh-keygen -R {RPi-IP-Address}? Commented Jun 23, 2017 at 16:37
-
I tried the command, but it just gives me the following error: ssh-keygen: /home/.ssh/known_hosts: No such file or directory @ginginsha– IliyanCommented Jun 23, 2017 at 17:25
-
That is because root is not configured for SSH, Like I said you should not login as root. Commented Jun 23, 2017 at 17:30
To begin first of all you should NOT be using a the pi while connected to the internet with open ssh ports and default credentials allowed, this is madness. Your machine is likely already compromised in the worst case and will be after not to long in the best case.
Step 1. Reformat the sd card and reboot the pi ideally with a screen and keyboard, or if thats not possible then i would suggest doing the following quickly. https://www.raspberrypi.org/documentation/installation/installing-images/
Step 2. Boot the os either ideally with no internet and begin by adding a new user
sudo adduser username
Add the new user to sudo privilages,
sudo visudo
Under root or pi add your username and permissions
%root ALL=(ALL:ALL) ALL
username ALL=(ALL:ALL) ALL
Step 3. you want to configure and allow ssh connections either from the gui menu, adding the ssh file to the sd card before boot or using
sudo raspi-config
now you want to edit the sshd config file to deny certain users and allow others
sudo nano /etc/ssh/sshd_config
There are many options but the bare minimum here would be
AllowTcpForwarding yes CHANE TO AllowTcpForwarding no
X11Forwarding yes CHANGE TO X11Forwarding no
PermitRootLogin no
DenyUsers pi
AllowUsers username
You should also consider either, changing the default pi users password to something long and secure (my suggestion) or deleting the pi account entirely. But the above should be the bare minimum to securing your raspberry pi and only allowing access to you, not everyone.
Ideally you might look at ssh keys for access instead
-
Thank you very much! I'll now try and see if it works. @leviataint– IliyanCommented Jun 24, 2017 at 7:18
-
Hopefully that will give you a working system, there are several other options you can edit within sshd_config just read the manual. And i would suggest ssh keys which are more secure and sometimes easier then keys Commented Jun 24, 2017 at 11:23
-
I tried your commands, but now when I try to configure my pi from system settings and reboot it, the changes aren't saved. @leviataint– IliyanCommented Jun 24, 2017 at 11:44
-
did you sudo raspi-config or enter settings from the menu. also you need to edit sshd_config file with sudo privilages or by changing to root with su first Commented Jun 24, 2017 at 11:47
-
YES!!! Finally got it to work! I installed Raspbian Jessie this time, not NOOBS, I introduced a modified version of @leviataint 's code, changed my Pi's password, and finally managed to SSH using the Pi username.