September 25, 2019

SSH: How to identify which key to use when AgentFowarding is in use

https://superuser.com/questions/273037/using-the-identityfile-directive-in-ssh-config-when-agentforwarding-is-in-use 


You can use the public part of a key to to specify which private key you want to use from the forwarded agent. This requires creating an extra file (the public part of the key) on any “intermediate” machines (machines to which you forward your local ssh-agent).
  1. Arrange for the intermediate machine to have a copy of the public part of the desired key in a convenient location (e.g. ~/.ssh/some_other_key.pub).
    From any machine that already has the public part of the key:
    scp some_other_key.pub intermediate:.ssh/
    
    or, on the intermediate machine:
    ssh-add -L | grep something_unique > ~/.ssh/some_other_key.pub
    
    You may want to edit the trailing “comment” part of the public key to better identify the key’s origin/owner/purpose (or attempt to hide the same).
  2. Use the pathname to the above public key file with -i or IdentityFile.
  3. You may also need to use IdentitiesOnly yes (in .ssh/config or -o) to keep ssh from trying to offer any additional identities from your forwarded agent.

September 8, 2019

Lego EV3 Sound file .rsf format

Lego EV3 support play sound files, and the Lego programmer software comes with many built-in sound files. If you want to add new sound files,  you can use the "Sound Editor" that came with the software. Or you can convert an existing sound file to it.

The found file ends with .rsf extension (probably standing for Robotic Sound File). It has the following format:

[ 8 bytes of header]
[ raw sound data ]

The first 8 bytes of the file are meta data with the following meaning:

byte 0, byte 1: 0x01 0x00
byte 2, byte 3:  length, in big-endian, of raw sound data.
byte 4, byte 5: 0x1f, 0x40 (demical 8000, the sampling rate)
byte 6, byte 7: 0x00, 0x00.

raw sound data
The raw sound data is 8-bit of PCM data, with sampling rate of 8000 samples per second.

Example Script

On a Mac OS computer, one can use the following command to generate a audio file:
say "hello world" -o hello.aiff

Then you can use "ffmpeg" (you need to use brew to install it) to convert it to raw audio
ffmpeg -i hello.aiff -acodec pcm_u8 -f u8 -ar 8000 hello.raw

Then you can use the above mentioned tool "raw2rsf" to conver the raw file to .rsf file
raw2rsf hello.raw > hello.rsf

Then you can copy the hello.rsf file to your Lego Programmer sound file directory and then use it from the programmer software!



raw2rsf.c: a simple C program to convert a .raw file to .rsf file.