User avatar
kusti8
Posts: 3439
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: Headless SSH Not Initializing Properly

Wed Dec 21, 2016 1:23 am

100,000 of 10 million is 1% of users, very roughly. Is it the foundations fault that some person who configured port forwarding didn't even change the password? If something is automatically exposed to the Internet I get it, but for a Pi, where Raspbian is designed for ease of use and education, you have to setup a webserver. How is changing the password not somsthing that is automatically done?
There are 10 types of people: those who understand binary and those who don't.

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

Re: Headless SSH Not Initializing Properly

Fri Dec 23, 2016 6:42 am

fsr wrote:Sorry, don't agree with you here.
Agree raspbian has a major security problem but disabling ssh does not improve security at all. It is just sweeping the problem under the carpet. The underlying issues are still there waiting to be exploited when ssh gets enabled.

Specifically these items:
1) sudo for the default 'pi' user is passwordless. (bzzz fail)
2) you are not forced to change the 'pi' password, create a user or anything.
3) the (ab)use of root in day to day activities - 'sudo' is stuck in front of everything.
I said it was a step in the right direction, not a complete fix. I agree with you, and I'm pretty sure I have griped about all those things in the past as well, but they make one little change and look what is happening. So much bellyaching from the masses that don't bother to read release notes or the blog.

Baby steps...
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?

ilw
Posts: 1
Joined: Wed Apr 26, 2017 11:17 am

Re: Headless SSH Not Initializing Properly

Wed Apr 26, 2017 11:24 am

Just wanted to bump this as it was the only thread i found talking about the issue. The placing of a ssh file in the boot folder did not work properly for me for headless setup of a clean jessie lite instance. SSH was started but refused all connections. I had to get a keyboard and display and login to see the problems. I found that i couldn't even ssh to localhost until i did:

sudo rm /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server

Then everything started working fine. No idea why.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6086
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Headless SSH Not Initializing Properly

Wed Apr 26, 2017 1:20 pm

That happens when power is removed while host keys are being generated.

Ernst
Posts: 1257
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Headless SSH Not Initializing Properly

Wed Apr 26, 2017 2:16 pm

ShiftPlusOne wrote:That happens when power is removed while host keys are being generated.
I would like to add that the time for this process seems to depend on the size of the SD card because of extending the partition/file system on first boot. For this reason it is recommended to be patient, wait a few minutes before trying to access with ssh, do not remove the power immediately. The best practice is to wait for the activity LED to stop blinking.
The road to insanity is paved with static ip addresses

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6086
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Headless SSH Not Initializing Properly

Wed Apr 26, 2017 2:25 pm

Ernst wrote:
ShiftPlusOne wrote:That happens when power is removed while host keys are being generated.
I would like to add that the time for this process seems to depend on the size of the SD card because of extending the partition/file system on first boot. For this reason it is recommended to be patient, wait a few minutes before trying to access with ssh, do not remove the power immediately. The best practice is to wait for the activity LED to stop blinking.
I would expect the partition resize to take the same amount of time regardless of the sd card size. Since it's only being expanded, no data is being moved. A lot of time on first boot goes towards creating the swap file, so it's possible that the speed of the sd card makes a small difference there.

hdoverobinson
Posts: 2
Joined: Thu Dec 15, 2016 5:02 am

Re: Headless SSH Not Initializing Properly

Thu May 11, 2017 8:12 pm

@ShiftPlusOne thank you for clarifying the power issue. I should have followed up on this post but for some reason was never notified of any responses and had long forgotten about it. With the latest version of NOOBS and using an RPI 3 and a Sandisk Micro SD card, I am no longer experiencing this issue. I am following the same procedure that I was before but now without any problems:

1. Format SD card
2. Extract NOOBS
3. Run installer over VNC
4. Shut off Pi
5. Add empty "ssh" file to boot partition
6. Boot up Pi

I'd like to provide a post-mortem to this thread in case anyone reads through it looking for information:

As @HawaiianPi graciously pointed out, it is not ideal to pull the power on a running Linux machine. The reason that I did this was because for some reason, (and the real underlying issue in this case) the SSH keys were not being generated within a reasonable amount of time after the first boot. As it was a headless machine and I had no way of checking on its status without SSH, I powered it off after about 10-20 minutes of trying to log in via SSH. To date I still do not know why the SSH keys were not being generated. Either they were in the process of being generated and powering off the machine interrupted this, or, as I initially pointed out, the regenerate_ssh_host_keys.service might have been missing from that image of Raspbian.

I appreciate everyone's insight into this issue.

Thanks!

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

Re: Headless SSH Not Initializing Properly

Fri May 12, 2017 10:39 am

hdoverobinson wrote:... 2. Extract NOOBS...
There's your problem. For headless setups it's better to use the raspbian images. Why go to the trouble of using NOOBS when you can just write an image?

Your procedure...
1. Format SD card
2. Extract NOOBS
3. Run installer over VNC
4. Shut off Pi
5. Add empty "ssh" file to boot partition
6. Boot up Pi

My procedure...
1. Write image to SD card (using Etcher)
2. Add empty "ssh" file to boot partition
3. Boot up Pi
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?

Martin Frezman
Posts: 1020
Joined: Mon Oct 31, 2016 10:05 am

Re: Headless SSH Not Initializing Properly

Fri May 12, 2017 11:57 am

You didn't mention:

-3: Figure out where and how to find this "Etcher" thing.
-2: Find a machine that is capable of running it - a machine you're willing to take the risk of installing some new, unknown piece of software on.
-1: Download it - make sure that all works. Click install. Click OK on all the EULAs and hope you haven't signed your life away.
0: Figure out how to run it - make sure you're not overwriting your system disk.

The nice thing about NOOBS/PINN is that it doesn't require any new/untrusted software to be installed on your non-Linux systems.

That all said, yes, NOOBS/PINN is not particularly well-suited to "Headless" installs, but it can be done. The people who set NOOBS/PINN up went to some lengths to make it work.
If this post appears in the wrong forums category, my apologies.

ethrbh
Posts: 2
Joined: Thu Oct 19, 2017 9:03 am

Re: Headless SSH Not Initializing Properly

Thu Oct 19, 2017 9:24 am

hello,

I have been reading the all replies to this topic, but unfortunately I still have problem with enable SSH service on a newly burned Rasbian on the PI.

Below I would describe the steps I did, probably someone can point out what did I wrong

- download the 2017-09-07-raspbian-stretch.img
- burn it on the SD card with Win32DiskImager tool
- for able to write the Linux partition under Windows, I use Paragon ExtFS tool
- mount the Linux partition on the SD card with the Paragon ExtFS tool on Windows
- in Totalcommander, I can see the mounted Linux partition under the Y driver
- enter to the Y:\boot folder
- create and save the Y:\boot\ssh file
- unmount the SD from the Windows system, and pull out from the SD card socket
- insert the SD card in the Pi
- in my own router, a fix IP address is assigned to the PI's MAC address, thus I can check when the PI is alive by ping the PI's IP from the Windows's cmd tool
- when I got such ICMP reply, I try SSH to the PI via PUTTY, but I got "connection refused" all the time

- if I power off the PI after a while, ~10 min, and plug in the SD card into the Windows, and doing the above mentioned mount steps, I can see the /boot/ssh file is removed. If I repeat the steps above for making this file, and try SSH login, I got the same failure.

Please try help me.

thanks for your help,
/Robi

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6086
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Headless SSH Not Initializing Properly

Thu Oct 19, 2017 10:11 am

You don't need to write to the /boot directory. You need to write to the boot PARTITION, which is the one which contains start.elf.

drgeoff
Posts: 9927
Joined: Wed Jan 25, 2012 6:39 pm

Re: Headless SSH Not Initializing Properly

Thu Oct 19, 2017 11:35 am

To be absolutely clear. You make a file named ssh or ssh.txt in the top level of the only drive that native Windows sees on the card. No need for Paragon or any other means of getting into Linux file systems.

ethrbh
Posts: 2
Joined: Thu Oct 19, 2017 9:03 am

Re: Headless SSH Not Initializing Properly

Thu Oct 19, 2017 12:05 pm

hello ShiftPlusOne and drgeoff,

Thanks for your help. I did what you suggested and this working fine. I could SSH into the PI.

I don't know, but probably the chapter 3. of this page https://www.raspberrypi.org/documentati ... ccess/ssh/ would be good to update, and make a more clearer description. Maybe not only me has misunderstood the way for enable SSH.

anyway, thanks for your help again.
/Robi

Return to “Troubleshooting”