totolino29
Posts: 3
Joined: Fri Jun 08, 2018 5:23 pm

Putty "Unknown error" using SSH with pi zero over USB

Fri Jun 08, 2018 6:37 pm

I decided to create this topic as I couldn't find any with the error I received.
I'm using a Windows 10 pc to ssh into my headless pi zero through USB.
I modified the sd card to allow it to work through ssh.
My pc can detect the pi as an unidentified network, however when I try to ssh using raspberrypi.local Putty returns with the error:
"Unable to open connection to raspberrypi.local gethostbyname: unknown error"

I don't think this is an issue with Bonjour, as I installed it and even updated itunes just to make sure.
I also disabled the windows firewall and enabled internet sharing connection but none of these methods worked.

Do you guys have any ideas ?

echmain
Posts: 79
Joined: Fri Mar 04, 2016 8:26 pm

Re: Putty "Unknown error" using SSH with pi zero over USB

Fri Jun 08, 2018 8:11 pm

Can you try connecting using the ip address instead of the name?

Mine is 10.0.1.18 for example.

totolino29
Posts: 3
Joined: Fri Jun 08, 2018 5:23 pm

Re: Putty "Unknown error" using SSH with pi zero over USB

Tue Jun 12, 2018 5:38 pm

echmain wrote:
Fri Jun 08, 2018 8:11 pm
Can you try connecting using the ip address instead of the name?

Mine is 10.0.1.18 for example.
I did this, but Putty sends back "Connection refused" as an error

User avatar
DougieLawson
Posts: 33609
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Putty "Unknown error" using SSH with pi zero over USB

Tue Jun 12, 2018 5:52 pm

totolino29 wrote:
Fri Jun 08, 2018 6:37 pm

My pc can detect the pi as an unidentified network, however when I try to ssh using raspberrypi.local Putty returns with the error:
"Unable to open connection to raspberrypi.local gethostbyname: unknown error"

I don't think this is an issue with Bonjour, as I installed it and even updated itunes just to make sure.
Of course that's an error with Bonjour. It can't resolve the raspberrypi.local name. Is the avahi-daemon running on your Raspberry.

To find it use https://www.fing.io or http://www.advanced-ip-scanner.com to scan your network.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

totolino29
Posts: 3
Joined: Fri Jun 08, 2018 5:23 pm

Re: Putty "Unknown error" using SSH with pi zero over USB

Tue Jun 12, 2018 6:10 pm

Actually I had the wrong ip adress that whole time, and it now works ! Thanks for the help or I wouldn't have looked into it otherwise.

raspiem
Posts: 2
Joined: Mon Jun 25, 2018 7:20 am

Re: Putty "Unknown error" using SSH with pi zero over USB

Mon Jun 25, 2018 7:40 am

Hello there,
I'm a complete newbie at this, so please forgive me if I sound ignorant.

I'm also having the same issue, but the circumstances are a little different. I only started getting this error after following these steps from this site https://raspberrypi.stackexchange.com/q ... on-network:

Alternatively, your PI isn't providing a hostname. I forgot to set up my tunnel into my Pi from here, so don't recall which DHCP client it's using. If dhclient, which I think it is, /etc/dhclient.conf should contain:

send host-name = gethostname();

alternatively the following in /etc/network/interfaces

iface wlan0 inet dhcp
hostname Something


Since that point, I've formatted my SD card and used Etcher to flash Raspbian Stretch on my card. I then edited the cmdline.txt like this:

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=b4af9f39-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether quiet splash plymouth.ignore-serial-consoles

And I added the following to config.txt file:

dtoverlay=dwc2

Both files were edited using Notepad++. I also created an ssh file.

Before I made the gethostname changes, I was able to SSH into both [email protected] and [email protected] (the IP address), now I get the 'gethostname: unknown error'. ARGH, I'm so frustrated, it's like the change I made is still being seen even after I formatted the SD card? I finally made progress and got it on the network and was able to SSH in, now it's all messed up.

Note that in the:

iface wlan0 inet dhcp
hostname Something


I wrote 'raspberrypi0w' in place of the 'Something' . Because of that, I also tried connecting in SSH using [email protected] and get 'host does not exist'.

I cannot connect via IP address, because I can't seem to get it to connect to my Wifi using the wpa_supplicant.conf file, when it was able to connect before. I used a scanner tool, but the device isn't found.

I feel like I've really screwed something up here. Any advice?

pcmanbob
Posts: 4262
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Putty "Unknown error" using SSH with pi zero over USB

Mon Jun 25, 2018 9:23 am

Hi.
I cannot connect via IP address, because I can't seem to get it to connect to my Wifi using the wpa_supplicant.conf file,
if you don't have you pi connected to the network, so it does not have an IP address the trying to use the hostname to connect to it wont work either because its not connected to the network.

the pi has to be connected to the network and have an IP address before you can connect to it.
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

jbudd
Posts: 687
Joined: Mon Dec 16, 2013 10:23 am

Re: Putty "Unknown error" using SSH with pi zero over USB

Mon Jun 25, 2018 2:16 pm

I'm not clear if you prefer to access your Pi 0 W by wifi or via USB.

The Pi's hostname is defined in /etc/hosts and /etc/hostname. There is an option in raspi-config | Network configuration to change it.
With Raspbian Stretch you should not normally change anything in /etc/network/interfaces

All you need to be able to connect by ssh over wifi is:
A newly burned SD with Raspbian Stretch
A file "ssh" in the boot partition
A file "wpa_supplicant.conf" in the boot partition which must define the country code (a new requirement for Stretch). For a WPA/WPA2 network it should look like this

Code: Select all

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

network={
        ssid="MyRouterSSID"
        psk="Password1"
}
With that setup you should be able to connect by ssh [email protected]_ADDRESS and perhaps [email protected]
Then change the hostname, reboot (might be worth rebooting the router too) and ssh [email protected] should work

raspiem
Posts: 2
Joined: Mon Jun 25, 2018 7:20 am

Re: Putty "Unknown error" using SSH with pi zero over USB

Mon Jun 25, 2018 5:19 pm

Thank you so much for getting back to me. I made some progress just after writing that. I found a forum post that said that in the wpa_supplicant.conf, you have to add this part at the top:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=us

Which I had in there when it was working, but had accidentally left it out after reformatting and starting again. Now that it's there, I was able to get it on my network, and use Remote Desktop to get to the desktop.

I looked at the changes I had made in this quote and they no longer existed, which is a good thing.
Alternatively, your PI isn't providing a hostname. I forgot to set up my tunnel into my Pi from here, so don't recall which DHCP client it's using. If dhclient, which I think it is, /etc/dhclient.conf should contain:

send host-name = gethostname();

alternatively the following in /etc/network/interfaces

iface wlan0 inet dhcp
hostname Something
The only problem is, I still can't get to it via USB connection when using [email protected]. I can see that the host name is raspberrypi, so I don't understand why it's still giving me that 'gethostname: unknown error'. It's quite frustrating. I haven't been able to reboot my PC yet, but I'll try that and rebooting my router. Perhaps that will clear it up. The reason why it's bothering me is because well for one thing, it bothers me when something should work, but doesn't. Also because I want to take it elsewhere and rather than just connecting via my micro USB cable (which I always have) to change the WIFI SSID and passkey, I'll have to make sure I have an SD card reader on me as well.

User avatar
HawaiianPi
Posts: 2657
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Putty "Unknown error" using SSH with pi zero over USB

Tue Jun 26, 2018 4:12 pm

Try this image I made.
2018-04-18-raspbian-stretch-lite_Pi0USB.zip
2018-04-18-raspbian-stretch-lite_Pi0USB.zip.sha256

It's the default Raspbian Stretch Lite 2018-04-18 image with Pi0(W) USB Ethernet Gadget mode pre-configured (config/cmdline .txt files modified and "ssh" file added with no other changes). Just write it you your SD card with Etcher and DO NOT modify anything.
  • Put the card in your Pi0 or Pi0W
  • Connect a normal micro USB data cable to the USB data port of the Pi0 (the one closest to the center)
  • Do not connect anything to the power port (the one closest to the outer edge)
  • Connect the other end of the micro USB cable to your main PC and the Pi0 should start to boot
  • Note that the first boot can take awhile, so give it a couple of minutes before you try to SSH in
It should boot up in USB Ethernet Gadget mode. If it works then you had a problem with editing your files.

If it doesn't work, check Device Manager to see what driver (if any) was installed.

If you don't see this USB Ethernet/RNDIS Gadget driver,
Image
then something is wrong with your Windows system (it's installing the wrong driver), and you can try this driver (all the details match the driver installed in my Win10 system). Other hardware - Acer USB Ethernet/RNDIS Gadget

If you DO see that driver but it has a problem, right click on it and uninstall it, then click on scan for hardware changes in the Action menu. If that doesn't fix it you can try the driver linked above.

If the driver appears to be working, but you can't SSH into [email protected] (or [email protected]) then Zeroconf is not working on your system.

This image was tested and confirmed working on my Windows 10 notebook with my Pi0W.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

Return to “Troubleshooting”

Who is online

Users browsing this forum: No registered users and 54 guests