Linux 通过命令行自动化 VNC 授权过程

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5020858/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 02:53:22  来源:igfitidea点击:

Automating VNC authorization process through command line

linuxterminalcommand-promptvncvnc-viewer

提问by Arihant Nahata

I am receiving a input as vnc://172.16.41.101&passwd=test

我收到的输入是 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.

我想用这个输入做的是:
1. 提取 IP 地址。
2. 提取密码。
3. 使用提供的 IP 和密码启动 vncviewer。
4. 一旦收到输入,所有这些都应该是自动化的。

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 ?

提取IP和密码很容易。然后我使用提供的 ip 启动 vncviewer,但是如何在不提示用户输入密码的情况下将密码传递给它?

回答by Bruno Flávio

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

假设(通过标签)您正在使用命令提示符中的 vncviewer 程序,我认为您可以执行以下操作:

echo "password" | vncviewer -autopass host:display

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

使用您的示例:vnc://172.16.41.101&passwd=test

echo "test" | vncviewer -autopass 172.16.41.101

回答by Albert Peschar

If your vncviewerdoes not have the -autopassoption, you can use vncpasswdto generate a password file that can be passed into the -passwdoption:

如果您vncviewer没有该-autopass选项,您可以使用vncpasswd生成一个可以传递给该-passwd选项的密码文件:

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