How to generate a VNC password?
Asked Answered
vnc
E

2

5

Hi need to generate a vnc password using any script (php preferably but any perl will do).

Problem is that 'vncpasswd' needs interactive user action (prompting for password and password verification).

Is there a way to generate it without prompting ?

Elite answered 22/10, 2009 at 14:57 Comment(0)
M
5

Yes it's possible, folder /.vnc must exist and file rights have usually to be set.

So just do this:

mkdir $HOME/.vnc/

vncpasswd -f > $HOME/.vnc/passwd <<EOF
123456
123456
EOF

chmod 600 $HOME/.vnc/passwd
Monopode answered 30/4, 2020 at 21:0 Comment(1)
This helped me do full automation on starting a VNC server.Anus
R
4

From here.

#!/bin/perl

use Crypt::CBC;

my $key = pack("C8", 23, 82, 107, 6, 35, 78, 88, 7);
$cipher = Crypt::CBC->new({
'key'=>$key, 'cipher'=>'DES', 'prepend_iv'=>0, 'regenerate_key'=>0
});

$ciphertext = $cipher->encrypt("This data is hush hush");
$plaintext = $cipher->decrypt($ciphertext);

print "Encrypted: $ciphertext\n";
print "Decrypted: $plaintext\n";
Redstart answered 22/10, 2009 at 15:18 Comment(2)
Just a note: VNC passwords are truncated (or nul padded) to length 8 before encryption.Itself
github.com/billchaison/VNCDecrypt echo -n d7a514d8c556aade | xxd -r -p | openssl enc -des-cbc --nopad --nosalt -K e84ad660c4721ae0 -iv 0000000000000000 -d -provider legacy -provider default For openssl 3+, i think. For lower than 3 or 2, remove provider key-value pair options. For envrypting, remove the -d option.Kenway

© 2022 - 2024 — McMap. All rights reserved.