7

I am receiving a input as vnc://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 ?

Arihant Nahata
  • 1,802
  • 2
  • 19
  • 30
  • 1
    Not sure what you're asking here. What application are you writing, who is "I" in "I am receiving an input"? Are you writing a bash script? A native application? Are you just asking for the command line arguments of the vncviewer application? (Which vncviewer, there are lots?) If so, please consult its man page. – Henrik Heimbuerger Mar 04 '11 at 10:30
  • Check this cool `https://github.com/trinitronx/vncpasswd.py` tool out, it can generate an obfuscated password file, that VNC authorization needs. – massisenergy May 21 '20 at 16:29

4 Answers4

7

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
Albert Peschar
  • 521
  • 3
  • 4
  • For this answer to work, you'll need to install `tigervnc-tools` package to be able to use `vncpasswd`, otherwise you'll not be able to connect with only `vncviewer` – FdelS Aug 17 '23 at 11:33
6

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
Bruno Flávio
  • 778
  • 10
  • 27
0

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
NVRM
  • 11,480
  • 1
  • 88
  • 87
0

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!

BuvinJ
  • 10,221
  • 5
  • 83
  • 96