TigerVNC自动设置密码脚本

 新建sh脚本,复制以下命令。设置ssh终端密码和vncserver密码后,运行ssh脚本,即可设置修改vncserver密码。

#!/bin/bash
vncpwd="vncserver密码"
sshpwd="ssh终端密码"

expect << EOF
    set timeout 10
    spawn ssh [email protected]
    expect {
        "yes/no" {send "yes\n"; exp_continue}
        "password:" {send "${sshpwd}\n"}
    }
    expect "#" {send "vncpasswd\n"}
    expect "Password:" {send "${vncpwd}\n"}
    expect "Verify:" {send "${vncpwd}\n"}
    expect "Would you like to enter a view-only password (y/n)?" {send "n\n"}
    expect "#"
    send "exit\n"
    expect eof
EOF

前提需要安装expect组件

yum方式安装

yum install expect

expect相关知识:

Linux之expect命令,以及实战使用!!!_大数据__GAI_-华为云开发者联盟

你可能感兴趣的:(java,服务器,前端,vnc,TigerVNC密码,脚本,自动化)