3

I want to use my RPi 3 completely headless with wifi using Raspbian - I don't have neither a USB keyboard nor a monitor. I modified the following two files on the ext4 partition of my SD card.

The content of /etc/wpa_supplicant/wpa_supplicant.conf:

country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
  ssid="XXXX"
  psk="YYYY"
}

I add the the following lines to /etc/dhcpcd.conf:

interface wlan0
static ip_address=192.168.0.200/22
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

And finally I added an empty ssh file to the boot partition. I've tried to ping the RPi and it seems to be online:

PING 192.168.0.200 (192.168.0.200) 56(84) bytes of data.
64 bytes from 192.168.0.200: icmp_seq=1 ttl=64 time=67.4 ms
64 bytes from 192.168.0.200: icmp_seq=2 ttl=64 time=5.59 ms
64 bytes from 192.168.0.200: icmp_seq=3 ttl=64 time=8.87 ms
64 bytes from 192.168.0.200: icmp_seq=4 ttl=64 time=9.06 ms
64 bytes from 192.168.0.200: icmp_seq=5 ttl=64 time=6.35 ms
64 bytes from 192.168.0.200: icmp_seq=6 ttl=64 time=6.65 ms
--- 192.168.0.200 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5005ms
rtt min/avg/max/mdev = 5.595/17.337/67.491/22.466 ms

But the command ssh [email protected] gives me an error:

ssh: connect to host 192.168.0.200 port 22: Connection refused

Do you have any idea why I can't ssh into my RPi?

4
  • 1
    Did you enable SSH? It's disabled by default.
    – Jacobm001
    May 15, 2017 at 4:32
  • I'm aware of that SSH is disabled by default. I read on many sites that it is possible to enable SSH by creating a file ssh without any file extensions in the boot directory. Is that possible that the SSH is still disabled? May 15, 2017 at 8:58
  • Did you really create the ssh file in the boot partition or accidentally in the boot folder on the other partition?
    – Uwe Plonus
    Mar 17, 2018 at 20:05
  • Connection refused has three possible causes: 1. Wrong IP address, 2. Right IP address, wrong port. 3. Right IP address, right port, listener not listening. Three things to check.
    – Dougie
    Dec 4, 2021 at 9:57

3 Answers 3

1

Yes, it is simply that port 22 is not listening.

First, fix your static IP address in dhcpcd.conf by removing the "/22" - you actually have a "/24" address which means your netmask is 255.255.255.0

Then go into

raspi-config

and turn on SSH. It will ask you to reboot.

At that point it will allow you to either ssh from another Linux box or use PuTTY.

Tidbit: In your ssh command you can add "pi@" to the IP address if you are already logged in with a different name on your Linux box. If you are already logged in as pi then it is not necessary.

7
  • If you want to go truly headless, then be sure to sudo apt-get install xrdp - then you will be able to use Remmina (Linux) or Microsoft Remote Desktop (Windows) to get a full GUI interface.
    – SDsolar
    May 14, 2017 at 23:11
  • Thank you for the answer! I cannot turn on SSH with rasp-config command, because I don't have a USB keyboard. I read on many sites that it is possible to enable SSH by creating a new file called ssh in the boot partition without any file extension. I removed "\22" from dhcpcd.conf but I still get the same "Connection refused" error message. May 15, 2017 at 8:37
  • Good that you removed the /22. Take a look at this and you will see that you really will need a keyboard to accomplish this: roughlea.wordpress.com/raspberry-pi-experiences/…
    – SDsolar
    May 15, 2017 at 17:38
  • For what it's worth, I found a link that seems to confirm that "create a file" concept. It needs to be called ssh (lower case) and put into the directory /Volumes/Boot according to this source (which I do not recognize as being authoritative): howchoo.com/g/ote0ywmzywj/… - but I am dubious. I don't find that directory in my system.
    – SDsolar
    May 15, 2017 at 21:20
  • Here is an official source, look at section 3.: raspberrypi.org/documentation/remote-access/ssh I've created this "ssh" file in my boot partition, so in theory the SSH should be enabled. On the other hand, according to the link above the file is automatically deleted, when Pi enables the SSH - but I still have this file, which means the Pi didn't find the "ssh" file. Ahh... it seems I really need that USB keyboard. May 16, 2017 at 8:17
0

Make fresh raspbian install and make a file called "ssh" without any extensions in the boot directory.

This will fix the rest, since raspbian stretch it is not recommended to edit any network files except the dhcpcd.conf. This does include the wpa_supplicant.conf file.

1
  • Please differentiate more clearly between a directory and a partition. Placing the file in the /boot directory will not help as during boot the boot partition will be mounted over that.
    – Uwe Plonus
    Mar 17, 2018 at 20:08
0

enter image description here

Give the details of wifi accordingly eject card place in pi and start.

I am using mac here.

Mostly your problem will be ssh file having an extension.

ssh now and try again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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