开发者

Automating VNC authorization process through command line

I am receiving a input as vnc://开发者_StackOverflow中文版172.16.41.101&passwd=test

What i want to do with this input is :

1. Extract the IP address.

2. Extract the password.

3. Launch vncviewer with the ip and password provided.

4. All this should this be automated, once the input is received.

extracting the ip and password is easy. then i launch the vncviewer with the ip provided, but how do i pass the password to that without prompting the user for the password ?


Assuming (by the tags) that you are using the vncviewer program from the command-prompt i think you could do something like this:

echo "password" | vncviewer -autopass host:display

using your example: vnc://172.16.41.101&passwd=test

echo "test" | vncviewer -autopass 172.16.41.101


If your vncviewer does not have the -autopass option, you can use vncpasswd to generate a password file that can be passed into the -passwd option:

vncviewer -passwd <(vncpasswd -f <<<"password") host:display


The -autopass was unavailable in my version of vncviewer.

Neither the tool vncpasswd (Apparently comes with vnc-server).


Demo using xvfb, x11vnc, run the program gimp, if installed, in a virtual X env.

And display with vncviewer without prompting for a password.

x11vnc -storepasswd 1234 /tmp/vncpass
xvfb-run --listen-tcp --server-num 30 --auth-file /tmp/xvfb.auth -s "-ac -screen 0 1920x1080x24" gimp
x11vnc -rfbport 4544 -rfbauth /tmp/vncpass -display :30 -forever -auth /tmp/xvfb.auth
vncviewer -passwd /tmp/vncpass machine:4544

One liner:

x11vnc -storepasswd 1234 /tmp/vncpass && xvfb-run --listen-tcp --server-num 30 --auth-file /tmp/xvfb.auth -s "-ac -screen 0 1920x1080x24" gimp & x11vnc -rfbport 4544 -rfbauth /tmp/vncpass -display :30 -forever -auth /tmp/xvfb.auth & vncviewer -passwd /tmp/vncpass $(hostname):4544


Without more detail provided, it's hard to answer this perfectly, e.g. to post the code / commands / configurations to achieve what I'd suggest... For instance, you'd need to specific exactly which vnc server, client, the platform for each side, etc, etc.

That said, if you can redesign how all of this works - I recommend not using a password at all!

Instead, setup an SSH Tunnel, and use key pair authentication to secure it. You can even remove any firewall exceptions for VNC when using this plan!

If you do this, not only will you not have to provide a password, but the entire VNC system will be far more secure!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜