Save into HEX, restore from, VNC server silent install

I wanna save VNC server password so I can completely create an unattended VNC installation script. VNC server keeps password file encrypted and it can not be echo. It is not plain text. It is some very garbage value. It is possible to create a backup using the HEX editor and then, of course, the hex numbers will be readable with the human eye. In this case, it is possible to restore file content by using HEX content as source.

Make sure xxd command is installed:
sudo apt-get install hexedit
Create a plain hex backup of file:
xxd -p ~/.vnc/passwd > ~/plain.hex
Restore with:
xxd -p -r ~/plain.hex ~/.vnc/test
Check the diferrence:
md5sum ~/.vnc/passwd
md5sum ~/.vnc/test
rm ~/.vnc/test
Talking about VNC server and passwd file.. It always needs exactly these permisions:
sudo chmod 600 /home/pi/.vnc/passwd
Otherwise nothing will work at all!

This is very life changing stuff!

No comments: