CentOS7部署VNC
16lz
2021-01-22
CentOS 7 安装 VNC 实现远程桌面
系统环境:CentOS 7.x
1. 安装 GNOME 桌面
# 安装 GNOME Desktopyum groups install "GNOME Desktop"# 修改默认启动方式为图形化界面systemctl set-default graphical.target# 设置成命令模式#systemctl set-default multi-user.target# 安装开发工具和组件yum groups install "Development Tools"yum groups install "Compatibility Libraries"# 重启系统【建议】reboot# 或者开启图形界面startx
2. 安装 VNC 客户端和服务端
yum install tigervnc tigervnc-server -y
3. 配置 VNC 服务
# 复制 vncserver 的服务模板并配置使用cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@\:1.servicecp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@\:2.service# 每个用户都需要单独这只一个监听服务,且配置不同# 修改 vncserver@\:1.service 为 root 用户的配置vim /etc/systemd/system/vncserver@\:1.service------------------------------------------------------------------------------[Unit]Description=Remote desktop service (VNC)After=syslog.target network.target[Service]Type=forkingUser=root# Clean any existing files in /tmp/.X11-unix environmentExecStartPre=-/usr/bin/vncserver -kill %iExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"PIDFile=/root/.vnc/%H%i.pidExecStop=-/usr/bin/vncserver -kill %i[Install]WantedBy=multi-user.target------------------------------------------------------------------------------# 修改 vncserver@\:2.service 为 huawei 用户的配置vim /etc/systemd/system/vncserver@\:2.service------------------------------------------------------------------------------[Unit]Description=Remote desktop service (VNC)After=syslog.target network.target[Service]Type=forkingUser=root# Clean any existing files in /tmp/.X11-unix environmentExecStartPre=-/usr/bin/vncserver -kill %iExecStart=/sbin/runuser -l huawei -c "/usr/bin/vncserver %i"PIDFile=/home/huawei/.vnc/%H%i.pidExecStop=-/usr/bin/vncserver -kill %i[Install]WantedBy=multi-user.target------------------------------------------------------------------------------
4. 设置 VNC 密码【VNC 的密码和系统用户密码不一样】
# 给 root 账号设置 VNC 密码# 这里不添加只读账号密码vncpasswd------------------------------------------------------------------------------Password:Verify:Would you like to enter a view-only password (y/n)? nA view-only password is not used------------------------------------------------------------------------------# 给 huawei 账号设置 VNC 密码# 这里不添加只读账号密码su - huaweivncpasswd------------------------------------------------------------------------------Password:Verify:Would you like to enter a view-only password (y/n)? nA view-only password is not used------------------------------------------------------------------------------
5. 关闭 firewalld 和 selinux
# 关闭防火墙systemctl disable --now firewalld# 禁用 selinuxsetenforce 0sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/g' /etc/selinux/config# 重启系统【建议】reboot
6. 启动 VNC 服务【开机自动启动】
systemctl enable --now vncserver@\:1.servicesystemctl enable --now vncserver@\:2.service
更多相关文章
- centos7修改root密码
- 数据库密码配置项都不加密?心也太大了!
- 设置密码输入的默认值,以便可以读取
- 我正在尝试使用带有post方法的AJAX将用户名和密码发送到php文件
- PHP中对用户密码进行加密
- php扫马、内网查mysql数据库账号密码(内网webshell渗透)
- 豆瓣的账号登录及api操作
- PHP万能密码登陆
- 从mysql中选择加密密码