VNCServer在Linux下设置
生活随笔
收集整理的這篇文章主要介紹了
VNCServer在Linux下设置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.檢查vnc客戶端和服務器是否已經安裝:
[root@centos ~]$ rpm -q ?vnc-server?
2. 將用戶名稱加入到配置文件:?
(注:這里的“用戶名”是指linux系統用戶的名稱)?
[root@centos ~]# vi /etc/sysconfig/vncservers?
#?
# Uncomment the line below to start a VNC server on display :1?
# as my 'myusername' (adjust this to your own). You will also?
# need to set a VNC password; run 'man vncpasswd' to see how?
# to do that.?
#?
# DO NOT RUN THIS SERVICE if your local area network is?
# untrusted! For a secure way of using VNC, see?
# .
#VNCSERVERS="1:myusername"//這段為原有內容
注:這里用到vi命令,按下Insert鍵就可以輸入以下內容,輸入完成后,按ESC鍵跳到命令模式然后,輸入:w 保存文件:
# VNCSERVERS="1:root2:admin" # use the method for more user?
VNCSERVERS="1:root 2:admin " ? ? //這句就是添加用戶 可以添加多人?
#VNCSERVERARGS[1]="-geometry800x600"?
VNCSERVERARGS[1]="-geometry 1024x768" ? ?//這句應該是分辨率 可以不要
3. 設置用戶root的密碼?
[root@centos ~]$ vncpasswd?
Password:?
Verify:
4. 啟動VNC服務 ? ? ? ? ? ? ??
?[root@centos ~]# /sbin/service vncserver start?
Starting VNC server: 1:root [ OK ]
5. 修改VNCSERVER的窗口治理器?
[root@centos ~]#vi ~/.vnc/xstartup
#!/bin/sh ?
# Uncomment thefollowing two lines for normal desktop:?
# unsetSESSION_MANAGER?
# exec/etc/X11/xinit/xinitrc?
?
[ -x /etc/vnc/xstartup ]&& exec /etc/vnc/xstartup?
[ -r $HOME/.Xresources ]&& xrdb $HOME/.Xresources?
xsetroot -solidgrey?
vncconfig -iconic&?
xterm -geometry80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &?
#twm& ? ? ? ? ? ? ?//這里加個# ,用于注釋,加粗的為原有內容
gnome-session& ? //加上這行?
#startkde #kdedesktop #如果是用kde去掉這行前面的注釋號即可
?6. 重啟vncserver?
[root@centos ~]#/sbin/service vncserver restart
Shutting down VNC server: 1:root[ OK ]?
Starting VNC server: 1:root [ OK ]
7.查看VNC端口 ??
[root@ centos ~]#netstat -ntlp?
8.把防火墻端口打開 ? ? ?
[root@centos ~]#vi /etc/sysconfig/iptables?
找到以下的語句: ?
-A RH-Firewall-l-INPUT-j INPUT-j REJECT - reject-withicmp-host-prohibited ?
在此語句前面加上下面的內容: ?
[root@centos ~]#service iptables restart?
10. Windows登陸到VNC Server?
打開windows下的VNC客戶端
在服務器欄輸入?
192.168.159.129:1 (這里,我的VNC服務器在192.168.159.129上,用的是Display1(對應root帳號))?
加密:讓服務器選擇(默認)
[root@centos ~]$ rpm -q ?vnc-server?
package vnc-server? is not installed ?說明沒有安裝
運行yum install vnc-server進行安裝
vnc-server-4.0-8.1 ?說明安裝已經安裝了 只是沒開啟服務而已2. 將用戶名稱加入到配置文件:?
(注:這里的“用戶名”是指linux系統用戶的名稱)?
[root@centos ~]# vi /etc/sysconfig/vncservers?
#?
# Uncomment the line below to start a VNC server on display :1?
# as my 'myusername' (adjust this to your own). You will also?
# need to set a VNC password; run 'man vncpasswd' to see how?
# to do that.?
#?
# DO NOT RUN THIS SERVICE if your local area network is?
# untrusted! For a secure way of using VNC, see?
# .
#VNCSERVERS="1:myusername"//這段為原有內容
注:這里用到vi命令,按下Insert鍵就可以輸入以下內容,輸入完成后,按ESC鍵跳到命令模式然后,輸入:w 保存文件:
# VNCSERVERS="1:root2:admin" # use the method for more user?
VNCSERVERS="1:root 2:admin " ? ? //這句就是添加用戶 可以添加多人?
#VNCSERVERARGS[1]="-geometry800x600"?
VNCSERVERARGS[1]="-geometry 1024x768" ? ?//這句應該是分辨率 可以不要
3. 設置用戶root的密碼?
[root@centos ~]$ vncpasswd?
Password:?
Verify:
4. 啟動VNC服務 ? ? ? ? ? ? ??
?[root@centos ~]# /sbin/service vncserver start?
Starting VNC server: 1:root [ OK ]
5. 修改VNCSERVER的窗口治理器?
[root@centos ~]#vi ~/.vnc/xstartup
#!/bin/sh ?
# Uncomment thefollowing two lines for normal desktop:?
# unsetSESSION_MANAGER?
# exec/etc/X11/xinit/xinitrc?
?
[ -x /etc/vnc/xstartup ]&& exec /etc/vnc/xstartup?
[ -r $HOME/.Xresources ]&& xrdb $HOME/.Xresources?
xsetroot -solidgrey?
vncconfig -iconic&?
xterm -geometry80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &?
#twm& ? ? ? ? ? ? ?//這里加個# ,用于注釋,加粗的為原有內容
gnome-session& ? //加上這行?
#startkde #kdedesktop #如果是用kde去掉這行前面的注釋號即可
?6. 重啟vncserver?
[root@centos ~]#/sbin/service vncserver restart
Shutting down VNC server: 1:root[ OK ]?
Starting VNC server: 1:root [ OK ]
7.查看VNC端口 ??
[root@ centos ~]#netstat -ntlp?
8.把防火墻端口打開 ? ? ?
[root@centos ~]#vi /etc/sysconfig/iptables?
找到以下的語句: ?
-A RH-Firewall-l-INPUT-j INPUT-j REJECT - reject-withicmp-host-prohibited ?
在此語句前面加上下面的內容: ?
-A Rh-Firewall-l-INPUT-m state -state NEW-mtcp-p tcp-dport 5901 -j ACCEPT //5901為查看到的VNC的端口號
VNC的默認端口是5900,而遠程桌面連接端口則是5900+n(n是vncserver命令指定的)。如果使用“vncserver :1”命令啟動VNC Server,那么下面的端口應該是5901。
[root@centos ~]#service iptables restart?
10. Windows登陸到VNC Server?
打開windows下的VNC客戶端
在服務器欄輸入?
192.168.159.129:1 (這里,我的VNC服務器在192.168.159.129上,用的是Display1(對應root帳號))?
加密:讓服務器選擇(默認)
總結
以上是生活随笔為你收集整理的VNCServer在Linux下设置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: B cannot be cast to
- 下一篇: 斐波那契数列(一)--对比递归与动态规划