银河麒麟服务器操作系统V10【vnc配置多用户登录】

服务器 0

1.添加多用户(规划kingbase使用5901窗口,root使用5903);

adduser kingbase

2.配置文件;

cp -rp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.servicecp -rp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:3.service

 以root用户访问 VNC 为例,修改为以下内容:

vim /etc/systemd/system/vncserver@:3.service[Unit]Description=Remote desktop service (VNC)After=syslog.target network.target[Service]Type=forkingWorkingDirectory=/rootUser=rootGroup=rootPIDFile=/root/.vnc/%H%i.pidExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'ExecStart=/usr/bin/vncserver -autokill %iExecStop=/usr/bin/vncserver -kill %iRestart=on-successRestartSec=15[Install]WantedBy=multi-user.target

以kingbase用户访问 VNC 为例,编辑刚复制的新文件

vim /etc/systemd/system/vncserver@:1.service[Unit]Description=Remote desktop service (VNC)After=syslog.target network.target[Service]Type=forkingWorkingDirectory=/home/<USER>User=<USER>Group=<USER>PIDFile=/home/<USER>/.vnc/%H%i.pidExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'ExecStart=/usr/bin/vncserver -autokill %iExecStop=/usr/bin/vncserver -kill %iRestart=on-successRestartSec=15[Install]WantedBy=multi-user.target

修改为以下内容:

[Unit]Description=Remote desktop service (VNC)After=syslog.target network.target[Service]Type=simpleWorkingDirectory=/home/kingbaseUser=kingbaseGroup=kingbasePIDFile=/home/kingbase/.vnc/%H%i.pidExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'ExecStart=/usr/sbin/runuser -l kingbase -c "/usr/bin/vncserver :1"ExecStop=/usr/bin/vncserver -kill %iRestart=on-successRestartSec=15[Install]WantedBy=multi-user.target

3.设置root访问VNC的密码并启动服务;

[root]#systemctl daemon-reload    //重新加载系统配置文件(系统新增或配置文件发生变化时,都需要执行 daemon-reload 子命令)[root]#vncpasswdPassword:     //输入密码Verify:       //在输入一遍确认密码Would you like to enter a view-only password (y/n)? n[root]#systemctl start vncserver@:3.service    //启动服务[root]#systemctl enable vncserver@:3.service    //设置开机启动[root]#vncserver :3    //启动VNC的5903窗口

4.设置kingbase访问VNC的密码并启动服务;

[kingbase]$vncpasswordPassword:     //输入密码Verify:       //在输入一遍确认密码Would you like to enter a view-only password (y/n)? n[kingbase]$vncserver :1    //启动VNC的5901窗口

5.如果系统启用了防火墙,需要配置相应规则,否则连接不上:

//添加端口firewall-cmd --add-port=5901/tcp --permanentfirewall-cmd --add-port=5903/tcp --permanentfirewall-cmd --reload
//彻底关闭防火墙(安全方面不推荐)systemctl stop firewalldsystemctl disabled firewalld

6.测试可以正常登录访问。

也许您对下面的内容还感兴趣: