vnc server

vnc server 远程控制桌面。

在centos6和centos7上安装vnc颇有差别,差别在某些命令和vnc的配置文件上,但所有软件的安装,无非就是先装好,再配置。

vnc server的安装配置网上教程很多,这里只是做个标记。

以下是centos6安装vnc。

1.yum安装

yum -y install tigervnc-server

2.启动服务和配置

启动vnc服务:

vncserver #启动命令

查看vnc占用的端口,可能还需要iptables开放端口或者直接关闭防火墙。

netstat -ntlp | grep vnc 
#可以看到端口是5901等

配置文件是/etc/sysconfig/vncservers,将最后两行的'#'去掉,并改为:

VNCSERVERS="1:root"    # 表示 监听 5901 端口,root登录用户,也可以换成其他用户

VNCSERVERARGS[1]="-geometry 1200x800"    #设置分辨率

3.配置vnc密码

这个密码是用于vnc连接时的密码:

命令vncpasswd设置即可。

4.远程访问

用vnc viewer访问,输入ip的时候,格式这样:

192.168.5.102:1

后面跟的1是端口号,代表5901,5902就是2,如果是6开头的端口,就要写全了。

### VNC Server Setup Guide Setting up a VNC server involves several steps, including installing the necessary software, configuring the server, and ensuring it starts automatically on boot. Below is a comprehensive guide to help you through the process. #### Install VNC Server First, ensure that your system is up to date. For a CentOS system, you can update it using the following command: ```bash sudo yum update ``` After updating your system, install the VNC server package. If it's not already installed, you can do so with: ```bash sudo yum install tigervnc-server ``` #### Configure VNC Server Before starting the VNC server, you need to create a configuration file. Copy the sample configuration file to the appropriate location: ```bash sudo cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service ``` Edit the copied file to specify the user that will run the VNC server. Replace `<USER>` with the actual username: ```bash sudo nano /etc/systemd/system/vncserver@:1.service ``` Find the lines that look like this and change `<USER>` to the correct username: ``` ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i" PIDFile=/home/<USER>/.vnc/%H%i.pid ``` #### Set Up VNC Password Switch to the user account that will run the VNC server and set a password: ```bash su - <USER> vncserver ``` You will be prompted to enter and confirm a password. This password will be used to connect to the VNC server from a client. #### Create a Custom xstartup File The `xstartup` file controls what happens when the VNC server starts. You may need to edit this file to start a desktop environment. Navigate to the `.vnc` directory in the user's home folder and edit the `xstartup` file: ```bash cd ~/.vnc nano xstartup ``` Ensure the file includes commands to start the desktop environment. For example, to start a GNOME desktop, the file might include: ```bash #!/bin/sh unset SESSION_MANAGER exec /etc/X11/xinit/xinitrc ``` Make the `xstartup` file executable: ```bash chmod +x xstartup ``` #### Enable and Start the VNC Service Reload the systemd daemon to apply the changes and enable the VNC service to start on boot: ```bash sudo systemctl daemon-reload sudo systemctl enable vncserver@:1.service ``` Start the VNC service immediately: ```bash sudo systemctl start vncserver@:1.service ``` #### Connect to the VNC Server To connect to the VNC server from a client, open the VNC Viewer program, add the IP address and port number of the CentOS VNC server, and hit the Enter key [^3]. You should now be able to see the desktop environment of the server. #### Troubleshooting If the VNC server does not start automatically on boot, check the script that runs on boot to ensure it allows for password input. If the script does not provide an opportunity to input a password, the VNC server will not start [^2]. #### Customizing Display Settings If you need to change the default resolution when no display device is connected, you can modify the `/etc/X11/xorg.conf` file by adding the desired resolution settings within the `Display` subsection [^5]. #### Conclusion By following these steps, you should have a functional VNC server that starts automatically on boot and allows remote access to the desktop environment. If you encounter any issues, review the logs located in the `.vnc` directory of the user's home folder for troubleshooting information [^4].
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值