3

您好需要使用任何脚本(最好是 php,但任何 perl 都可以)生成一个 vnc 密码。

问题是“vncpasswd”需要交互式用户操作(提示输入密码和密码验证)。

有没有办法在不提示的情况下生成它?

4

2 回答 2

3

这里

#!/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";
于 2009-10-22T15:18:57.783 回答
2

是的,有可能,文件夹/.vnc必须存在并且通常必须设置文件权限。

所以只需这样做:

mkdir $HOME/.vnc/

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

chmod 600 $HOME/.vnc/passwd
于 2020-04-30T21:00:12.030 回答