This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Cannot generate ssh key
#1
Hi,

Strange problem.
After a reboot, a script that uses ssh to another server stopped working.
I found that the ssh key had disappeared from /lib/genohm-scada/storage.

I wanted to generate a new key with:

Code:
key = '/lib/genohm-scada/storage/id_rsa'
res = os.execute('dropbearkey -t rsa -f ' .. key)
log(res)
keyinfo = io.readproc('dropbearkey -y -f ' .. key)
log(keyinfo)
but no key is generated:

Code:
testing 07.05.2021 17:26:49
* string:
testing 07.05.2021 17:26:49
* number: 35584
Any idea what might be going on?
Thanks.
Reply
#2
Maybe the SD card is read-only? This will explain disappearing files after a reboot.
Reply
#3
(07.05.2021, 15:45)admin Wrote: Maybe the SD card is read-only? This will explain disappearing files after a reboot.

That key was there since a long time and it is only a month or so that I replaced the card...
I just rebooted the machine again and the test script that I created an hour ago is still there so the card seems to be ok..

What does the return code 35584 from the os.execute mean?
Reply
#4
Try running it like this. It might provide some info on what's wrong:
Code:
key = '/lib/genohm-scada/storage/id_rsa'
res = io.readproc('dropbearkey -t rsa -f ' .. key .. ' 2>&1')
log(res)
keyinfo = io.readproc('dropbearkey -y -f ' .. key .. ' 2>&1')
log(keyinfo)
Reply
#5
(08.05.2021, 10:15)admin Wrote: Try running it like this. It might provide some info on what's wrong:
Code:
key = '/lib/genohm-scada/storage/id_rsa'
res = io.readproc('dropbearkey -t rsa -f ' .. key .. ' 2>&1')
log(res)
keyinfo = io.readproc('dropbearkey -y -f ' .. key .. ' 2>&1')
log(keyinfo)

Segmentation fault!

Code:
testing 08.05.2021 12:48:52
* string: Failed reading '/lib/genohm-scada/storage/id_rsa'

testing 08.05.2021 12:48:52
* string: Generating key, this may take a while...
Segmentation fault
Reply
#6
Try changing the key file name to something else and check if the key generation fails or not. This indicates a possible hardware (CPU or RAM) fault. It can cause various issues like scripts failing randomly or services not working correctly.
Reply
#7
(08.05.2021, 14:30)admin Wrote: Try changing the key file name to something else and check if the key generation fails or not. This indicates a possible hardware (CPU or RAM) fault. It can cause various issues like scripts failing randomly or services not working correctly.

Same result with another file name.
Rebooted the machine and repeated: same result.

Shutdown the machine and powered down. Restarted: same result.
Tried with a dss key instead of rsa: same result.

Is there some logfile similar to the normal /var/log/messages that I could look at?
Some other process that I could run to see if there are also problems with that?

Thanks.
Reply
#8
I suspect this is a hardware problem so monitoring won't solve it. Send us an e-mail, maybe we can arrange a replacement CPU module for you.
Reply
#9
(10.05.2021, 06:50)admin Wrote: I suspect this is a hardware problem so monitoring won't solve it. Send us an e-mail, maybe we can arrange a replacement CPU module for you.

With the generous help from openrb I managed to replace the CPU module (thanks Edgars!). I would like to take this opportunity to emphasize the great level of support that we receive here!

Unfortunately this did not resolve the problem: I still get the segmentation fault:

Code:
testing 19.05.2021 09:06:21
* string: Generating key, this may take a while...
Segmentation fault

Even if this would have worked I ran into another issue: the library that prevents me from upgrading this LM complains about the license key.
I can see that the daemon reads the license key but apparently this is linked to the MAC address of the LM which changed also together with the CPU...

I wonder if I could copy the ssh key from another LM to this one?
Reply
#10
This script will create a key that has been generated on another LM:
Code:
key = 'AAAAB3NzaC1yc2EAAAADAQABAAABAQCyAiQPWmdF+BK4zJb8KIbebYH03v+K8x4mq6sK59k9t1dstpF5Um8LUK2dpwdcdI3hYme1fIwPvMJd3a/1GN06lnW+ASGSRalDxK0H7WXiKBnGpNMKo0SfKbd4+fXNUjdiemjYCGev1WP66MUq3bw9PN2ISXkm5YjOnvARwZVvK5JlXAo67Jsy0J2UXDX1EAEz7ekGx/RcpBPFzQzLEDG4j1Ny1QVfBsi7V9qfuf9L+mxqulpDy5FAG0Pksmzx/8XCL4a0c7iAvehi+5svMBCpS0zraf9W2rtdTaX7TH6zfv2ORxIDP1BIhQi4W9+zvETZPgU8i6VqyFfxDAgQ0TnTAAABADbUBftcoxagFFQrYA4HBZOZM0ATN666t3y9v486XmVuBVWM3j36MA3SKce3XMMTe2gCgWMbG6D1SQDUeZAKuomDMnz1qDt/jWU8PPeGHa2NIHNY7VAHfelwVfzDMPyu6DRC8+wmmplEJulvrNtJNOO/zZRe3Rwn8v2BYvx1HewBgYuNEyyTnBYGxFejYg08yOY/88C4aHJ5CYitHlSa+xPWV3jV/5uydNlsix2qFK9sKz+Un62oqAVz8ldBdFgFiBGiYvftTAPbkhnI5KsWawvFL3Q3azT0TuIzdfJE/TGUZkx5wSPxy3JGqTwkqw9O3TuoBrxnyxm2ikhLWjc/zeEAAACBAME4q9IQTTAzgm/T+0G4osRsOmkHJtPrlxAghYfIBb6y/7spdHRjA+PPFvCicKS4EUj4xUM6c98rXWaA/CunYxWVdR8tjmWsm592o51GHVR4LepgdmUeey70hIKgAvMCtrTy2jpjdV0FrjPOOrZCRNtQViR71i62I4rpiytr02r5AAAAgQDr2B3Veql0KIlftrFwNTzxQgv+z4L6tsiH8s8ncnle30s405fNwr0CWMTZ7mhyHzmVvTBgFOEFYBlOF6XGAM3XulsHFq58sK4eJGLEDh3KzJgHvzDJuPM4bBqhkmRCyXEB2wMnptqFTofaovwDeTQWylrFvAj+dexAbOnp4H7SKw=='
key = require('encdec').base64dec(key)
io.writefile('/lib/genohm-scada/storage/id_rsa', key)
os.execute('chmod 0600 /lib/genohm-scada/storage/id_rsa')
Reply
#11
(19.05.2021, 07:56), because that oneadmin Wrote: This script will create a key that has been generated on another LM:
Code:
key = 'AAAAB3NzaC1yc2EAAAADAQABAAABAQCyAiQPWmdF+BK4zJb8KIbebYH03v+K8x4mq6sK59k9t1dstpF5Um8LUK2dpwdcdI3hYme1fIwPvMJd3a/1GN06lnW+ASGSRalDxK0H7WXiKBnGpNMKo0SfKbd4+fXNUjdiemjYCGev1WP66MUq3bw9PN2ISXkm5YjOnvARwZVvK5JlXAo67Jsy0J2UXDX1EAEz7ekGx/RcpBPFzQzLEDG4j1Ny1QVfBsi7V9qfuf9L+mxqulpDy5FAG0Pksmzx/8XCL4a0c7iAvehi+5svMBCpS0zraf9W2rtdTaX7TH6zfv2ORxIDP1BIhQi4W9+zvETZPgU8i6VqyFfxDAgQ0TnTAAABADbUBftcoxagFFQrYA4HBZOZM0ATN666t3y9v486XmVuBVWM3j36MA3SKce3XMMTe2gCgWMbG6D1SQDUeZAKuomDMnz1qDt/jWU8PPeGHa2NIHNY7VAHfelwVfzDMPyu6DRC8+wmmplEJulvrNtJNOO/zZRe3Rwn8v2BYvx1HewBgYuNEyyTnBYGxFejYg08yOY/88C4aHJ5CYitHlSa+xPWV3jV/5uydNlsix2qFK9sKz+Un62oqAVz8ldBdFgFiBGiYvftTAPbkhnI5KsWawvFL3Q3azT0TuIzdfJE/TGUZkx5wSPxy3JGqTwkqw9O3TuoBrxnyxm2ikhLWjc/zeEAAACBAME4q9IQTTAzgm/T+0G4osRsOmkHJtPrlxAghYfIBb6y/7spdHRjA+PPFvCicKS4EUj4xUM6c98rXWaA/CunYxWVdR8tjmWsm592o51GHVR4LepgdmUeey70hIKgAvMCtrTy2jpjdV0FrjPOOrZCRNtQViR71i62I4rpiytr02r5AAAAgQDr2B3Veql0KIlftrFwNTzxQgv+z4L6tsiH8s8ncnle30s405fNwr0CWMTZ7mhyHzmVvTBgFOEFYBlOF6XGAM3XulsHFq58sK4eJGLEDh3KzJgHvzDJuPM4bBqhkmRCyXEB2wMnptqFTofaovwDeTQWylrFvAj+dexAbOnp4H7SKw=='
key = require('encdec').base64dec(key)
io.writefile('/lib/genohm-scada/storage/id_rsa', key)
os.execute('chmod 0600 /lib/genohm-scada/storage/id_rsa')

I will give that a try.
I suppose I can use the key that I have on my other LM because that one is already on the server that I want to ssh to?
Reply
#12
Well, I copied the key from my other LM4 but that did not help... I could not make a connection to the server. The ssh command returned a 35584 error (?)

After investigation It appeared that dropbearkey and ssh are both linked to /usr/sbin/dropbear and since dropbearkey gave a segmentation fault, it is very likely that ssh will not function also...

Is there anything else I could try?
Thanks.
Reply


Forum Jump: