Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: gtr2 on May 26, 2013, 12:24:09 AM

Title: [solved] openssh keeps generating new private/public keys on every boot
Post by: gtr2 on May 26, 2013, 12:24:09 AM
Hi there,
I must have spent a fairly long time trying to figure out what the problem might be but to no avail.
The steps so far ...
tce-load -iw openssh.tcz
sudo cp /usr/local/etc/ssh/sshd_config.example /usr/local/etc/ssh/sshd_config
sudo cp /usr/local/etc/ssh/ssh_config.example /usr/local/etc/ssh/ssh_config

I made the lot persistent:
nano /opt/.filetool.lst
usr/local/etc/ssh/sshd_config
usr/local/etc/ssh/ssh_config

Making openssh start on boot:
nano /opt/bootlocal.sh
/usr/local/etc/init.d/openssh start

The backup
filetool.sh -b
... or just
backup

I disabled password authentication in sshd_config. Why does openssl keep on generating private/public keys on every boot ?
I can't login to my Raspberry Pi using ssh
Permission denied (publickey,keyboard-interactive)

Any advice?
Thanks in advance.

PS: Using the <code> tag was not possible as I was continuously getting " Sorry, you are not allowed to post external links." error.
Title: Re: openssh keeps generating new private/public keys on every boot
Post by: bmarkus on May 26, 2013, 01:36:08 AM
Add the 6 generated keys to your backup.
Title: Re: openssh keeps generating new private/public keys on every boot
Post by: gtr2 on May 26, 2013, 01:53:44 AM
Thanks bmarkus but I had already done that, I made the following entries in opt/.filetool.lst:

usr/local/etc/ssh/ssh_host_dsa_key.
usr/local/etc/ssh/ssh_host_dsa_key.pub.
usr/local/etc/ssh/ssh_host_ecdsa_key.
usr/local/etc/ssh/ssh_host_ecdsa_key.pub.
usr/local/etc/ssh/ssh_host_rsa_key.
usr/local/etc/ssh/ssh_host_rsa_key.pub.

... and made a backup as well.

openssh keeps generating keys on every boot though

I have openssh running on Debian and Arch without any problem.
Title: Re: openssh keeps generating new private/public keys on every boot
Post by: Gerrelt on May 26, 2013, 02:24:56 AM

Try adding a "/" before the paths, like this:


/usr/local/etc/ssh/ssh_host_dsa_key.
/usr/local/etc/ssh/ssh_host_dsa_key.pub.
/usr/local/etc/ssh/ssh_host_ecdsa_key.
/usr/local/etc/ssh/ssh_host_ecdsa_key.pub.
/usr/local/etc/ssh/ssh_host_rsa_key.
/usr/local/etc/ssh/ssh_host_rsa_key.pub.

And are you sure the dot is supposed to be there at the end of the path ( I don't have any experience with openssh, I use dropbear)?
Title: Re: openssh keeps generating new private/public keys on every boot
Post by: bmarkus on May 26, 2013, 02:29:10 AM
In you mail you mentione only config file backup, not the keys. Sharing the whole file would have saved some time for us.

Referring to Debian or Arch is irrelevant. Core is not a derivate of them.

Finally, do not use a leading / in filetool.lst and remove . at the end.

It works here as expected.
Title: Re: openssh keeps generating new private/public keys on every boot
Post by: gtr2 on May 26, 2013, 02:59:17 AM
@ Gerrelt
I had already tried with and without the leading forward slash but to no avail
The culprit was the dot at the end of the lines.

@ bmarkus
All apologies, yes I should have posted the way you've just mentioned.
Sorted! I deleted the dot at the end of every line and now it's OK.

However, I'm still not able to connect to my RPi using SSH as I'm still getting the following error:
Permission denied (publickey,keyboard-interactive)
I guess I need to use one of those keys on my computer if I'm not mistaken? If so, how should I proceed?
Is there any way I could just disable to login based on those keys ?

PS: I was referring to Debian and Arch because I can easily login to my RPi without all those keys ( those weren't mandatory )
Title: Re: openssh keeps generating new private/public keys on every boot
Post by: Gerrelt on May 26, 2013, 03:19:59 AM
Finally, do not use a leading / in filetool.lst.

Hi bmarkus,
 
What's the reason behind this? Could you explain?

Greetings,

    Gerrelt.
Title: Re: openssh keeps generating new private/public keys on every boot
Post by: tinypoodle on May 26, 2013, 04:15:27 AM
That's simply how syntax of tar list works.
Title: Re: openssh keeps generating new private/public keys on every boot
Post by: tinypoodle on May 26, 2013, 05:26:36 AM
However, I'm still not able to connect to my RPi using SSH as I'm still getting the following error:
Permission denied (publickey,keyboard-interactive)
I guess I need to use one of those keys on my computer if I'm not mistaken? If so, how should I proceed?
Is there any way I could just disable to login based on those keys ?

It is neither clear what you are trying to achieve nor why you are using openSSH (which is much more complicated than dropbear).
Title: Re: openssh keeps generating new private/public keys on every boot
Post by: gtr2 on May 26, 2013, 05:57:16 AM
It is neither clear what you are trying to achieve nor why you are using openSSH (which is much more complicated than dropbear).
Well, I'm just trying to login to my RPi from my computer using Kitty or MobaXterm. I  don't feel like using Dropbear because I need SFTP and that's exactly the reason why I've always run openssh without any problems.
Sorry if these questions seem elementary to you experts but I'm trying hard to learn.
Title: Re: openssh keeps generating new private/public keys on every boot
Post by: bmarkus on May 26, 2013, 06:06:44 AM
Did you set passwd for tc or added a new user?
Title: Re: openssh keeps generating new private/public keys on every boot
Post by: tinypoodle on May 26, 2013, 06:20:27 AM
Well, I'm just trying to login to my RPi from my computer using Kitty or MobaXterm. I  don't feel like using Dropbear because I need SFTP and that's exactly the reason why I've always run openssh without any problems.

That doesn't explain
Quote
I disabled password authentication in sshd_config.
Title: Re: openssh keeps generating new private/public keys on every boot
Post by: gtr2 on May 26, 2013, 08:28:03 AM
Did you set passwd for tc or added a new user?
I set a password for tc.
Well, SFTP connection is working flawlessly by now. I must have done something wrong but after a new installation, things are looking all right.
Thanks a lot for your support :)
Title: Re: openssh keeps generating new private/public keys on every boot
Post by: gtr2 on May 26, 2013, 08:31:59 AM
That doesn't explain
Quote
I disabled password authentication in sshd_config.
Well, I reset password authentication to yes but that wasn't the sole issue. I've fixed the problem now.
Thank you very much ;)
Title: Re: openssh keeps generating new private/public keys on every boot
Post by: xyz-worx on May 27, 2013, 12:53:49 AM
Hi gtr2,

it's a good idea to give a short description, what else you did to resolve your problem.
It might help other user having similar troubles. Additionally you might mark this thread
as [SOLVED].

thanx

xyz-worx
Title: Re: openssh keeps generating new private/public keys on every boot
Post by: gtr2 on May 27, 2013, 02:21:34 AM
@ xyz-worx
Yes mate, I was about to do it anyway, sorry. So here we go then ....

A fresh copy of piCore
Code: [Select]
fdisk -ul
Code: [Select]
mount  /dev/mmcblk0p2 (mmcblk0p2 is my ext4 formatted partition)
Code: [Select]
tce-setdrive ( select mmcblk0p2 )

Set password for tc
Code: [Select]
passwdInstall openssh
Code: [Select]
tce-load -wi openssh.tczRun the following commnads:
Code: [Select]
sudo cp /usr/local/etc/ssh/sshd_config.example /usr/local/etc/ssh/sshd_config
sudo cp /usr/local/etc/ssh/ssh_config.example /usr/local/etc/ssh/ssh_config
Start openssh
Code: [Select]
sudo /usr/local/etc/init.d/openssh start ( the application will now generate some keys, give it a couple of seconds )

That should be it. Now you can ssh to your Raspberry Pi from your computer ( login: tc and password: the one you've set )

Once logged in let's make this persistent ( so that openssh won't generate new keys on every boot )

I'm using MobaXterm so it's quite easy to edit files using the internal editor. No need for installing nano on the Raspberry Pi.
Open
/opt/.filetool.lst
Add
Code: [Select]
etc/passwd
etc/shadow
usr/local/etc/ssh/ssh_config
usr/local/etc/ssh/sshd_config
usr/local/etc/ssh/ssh_host_dsa_key
usr/local/etc/ssh/ssh_host_dsa_key.pub
usr/local/etc/ssh/ssh_host_ecdsa_key
usr/local/etc/ssh/ssh_host_ecdsa_key.pub
usr/local/etc/ssh/ssh_host_rsa_key
usr/local/etc/ssh/ssh_host_rsa_key.pub
Save and exit.

Let's make openssh start on boot
Open
Code: [Select]
/opt/bootlocal.shAdd
Code: [Select]
/usr/local/etc/init.d/openssh startSave and exit.

The most important step, we have to backup the lot.
Run the following command:
Code: [Select]
filetool.sh -b
Reboot.

Title: Re: [solved] openssh keeps generating new private/public keys on every boot
Post by: Gerrelt on May 27, 2013, 09:30:08 AM
I saved your instructions as an how-to install openssh!

Thank you gtr2! :)
Title: Re: [solved] openssh keeps generating new private/public keys on every boot
Post by: gtr2 on May 27, 2013, 10:05:07 PM
@ Gerrelt
You're very welcome :)
Title: Re: [solved] openssh keeps generating new private/public keys on every boot
Post by: Gerrelt on July 16, 2013, 12:10:12 PM

I just used your instructions to install ssh and it worked flawlessly!
It is so nice to be able to ftp to the TinyCore Raspberry. :D :)
It also feels faster, but that might be my imagination.

Thanks again!