4

I have a problem with the keyboard of my laptop which doesn't work properly anymore. However I have full control of the laptop via ssh. The problem is that I use a self encrypting disk (Samsung 840 Pro). If I turn the laptop of I will perhaps not be able to login anymore because of the keyboard issue (which is probably a hardware issue). So I want to turn of the ata-password via ssh and hdparm before rebooting, then I can put the SSD into another PC and access it without problems.

The problem with:

hdparm --security-disable password /dev/sda

however is that my laptop (Dell Latitude E6400, german keyboard) seems to translate the characters to scan codes, so I tried something like:

hdparm --security-disable $(printf 'password' | tr '1234567890qwertyuiopasdfghjklzxcvbnm' '\2-\13\20-\31\36-\46\54-\62') /dev/sda 

as described here.

But this doesn't work and I guess the reason for this is that I need the correct scan-code translation (the one above seems to be for a us keyboard).

So how can I get the correct scan codes via ssh without typing the keys on my laptop?

Are there any other suggestions how to disable the password via ssh.

countermode
  • 7,373
  • 5
  • 31
  • 58
student
  • 17,875
  • 31
  • 103
  • 169
  • 1
    Have you tried plugging a USB keyboard into your laptop? – garethTheRed Aug 01 '14 at 10:20
  • This is only relevant on rebooting, but if I reboot and this doesn`t work, the ssd will be locked. So I will not try it. Just to get access at the moment I don't need it, since I have full access via ssh (including X) as long as I don't reboot my laptop. – student Aug 01 '14 at 10:31

1 Answers1

2

Scan codes are the same on all PC keyboards (except that there is variation with multimedia keys). They are determined by the position of the key, not by the labels on the keys (in fact the labels on the keys have no relationship whatsoever with the electric signals sent by the keyboard).

So for a German (QWERTZ) keyboard, simply swap y and z.

hdparm --security-disable $(printf 'password' | tr '1234567890qwertzuiopasdfghjklyxcvbnm' '\2-\13\20-\31\36-\46\54-\62') /dev/sda 

For a French or Belgian AZERTY keyboard:

hdparm --security-disable $(printf 'password' | tr '1234567890azertyuiopqsdfghjklmwxcvbn' '\2-\13\20-\31\36-\47\54-\61') /dev/sda 
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
  • Thanks. How should I handle upper case letters? What's about release scan codes? – student Aug 02 '14 at 05:47
  • @student If the BIOS records scan codes then it wouldn't distinguish between lowercase and uppercase letters. According to the link you give, uppercase letters are not allowed. The scan code for a key release is the keypress scan code plus 128 but I presume that they are not recorded. Note that I don't know whether your disk uses this scheme, I'm taking your word for it. – Gilles 'SO- stop being evil' Aug 02 '14 at 08:35