CentOS远程桌面

 nohup java RFrun > HX_PsePSSM.log 2>&1 &


环境:

CentOS 6.3 Final,桌面安装了除KDE的所有组件


1、安装服务

[plain]  view plain copy
  1. yum install tigervnc-server  

名字有点怪哦,CentOS5前叫vnc-server


2、运行并设置密码

[plain]  view plain copy
  1. vncserver[:1]  

输入密码,会生成相关的文件

[plain]  view plain copy
  1. xauth:  creating new authority file /root/.Xauthority  
  2.   
  3. New 'centos6-244:1 (root)' desktop is centos6-244:1  
  4.   
  5. Starting applications specified in /root/.vnc/xstartup  
  6. Log file is /root/.vnc/centos6-244:1.log  

3、配置用户

[plain]  view plain copy
  1. vim /etc/sysconfig/vncservers  
最后一行加入:

VNCSERVERS="1:root" 多个用户用空格分开,并要先su - 到那个用户运行vncserver[:n]来设定配置文件和密码


4、实用命令

usage: vncserver [:<number>] [-name <desktop-name>] [-depth <depth>]
                 [-geometry <width>x<height>]
                 [-pixelformat rgbNNN|bgrNNN]
                 [-fp <font-path>]
                 [-fg]
                 <Xvnc-options>...


       vncserver -kill <X-display>
       vncserver -list

vncserver[:n] 开服务

vncserver -list 看有几个在运行

vncserver -kill :n   杀掉第几个x-display

vncpasswd           修改密码


5、服务管理

service vncserver restart

其它用法:/etc/init.d/vncserver {start|stop|restart|try-restart|status|force-reload}

chkconfig vncserver on 加入到自启动(chkconfig --level 35 vncserver on)


6、客户端连接

CentOS:使用TigerVNC Viewer 连接 ip:1

Windows:使用Real VNC Viewer 连接ip:1

输入密码即可访问


===============================================================================================

必须明白:
vncserver在调用的时候,会根据你的配置来启用server端的监听端口,
端口默认是从5900开始,再加上你的桌面号。
比如你的桌面号为1,则vnc的连接端口号为5900+1=5901
比如你的桌面号为10000,则vnc的连接端口号为5900+10000=15900
======================================================================
下面配置VNC服务器,使用户(root)能够通过vnc客户端远程连接到linux系统的图形界面(前提是你的服务器要安装桌面)

1、检查linux系统是否安装VNC
在终端窗口输入命令:

rpm -q vnc-server

返回信息如下

package vnc-server is not installed

说明vnc服务器没有安装
2、运行以下命令进行安装:

yum install vnc vnc-server

3、启动VNC服务

vncserver
You will require a password to access your desktops.
Password:
Verify:

会提示输入密码,这个密码是远程登录时所需要输入的密码,输入密码,回车
4、切换到root账号:su root然后输入root账号的密码

vi /etc/sysconfig/vncservers  #vnc配置文件
VNCSERVERS="10000:root"  # 把前面的#取消了   10000:root (桌面号:用户)
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"

最后保存退出
5、配置防火墙,允许10000+5900=15900端口通过防火墙(否则远程连不上VNC服务器)

vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 15900 -j ACCEPT(允许15900端口通过防火墙)

保存退出
6、重启vnc服务器

 /etc/init.d/vncserver restart
或者
service vncserver restart

7、重启防火墙,使刚才的端口配置生效

/etc/init.d/iptables restart
service iptables restart

8、 设置vnc服务器开机自动启动
第一种方法:使用“ntsysv”命令启动图形化服务配置程序,在vncserver服务前加上星号,点击确定,配置完成。
第二种方法:使用“chkconfig”在命令行模式下进行操作,命令使用如下

chkconfig vncserver on
chkconfig --list vncserver
vncserver       0:off   1:off   2:on    3:on    4:on    5:on    6:off

9、更改vnc连接密码
vncpasswd
到此,VNC服务端设置完成,用VNC客户端可以连接了
vnc服务器:你的ip:15900

注意:如果在连接上之后,出现灰屏,可以按照下面的方法设置
进入用户的home目录, cd /home/user
如果是用root账号登录的,那么当前目录就是用户根目录

cd ~/.vnc
vi xstartup  #编辑
#twm &    #注释掉这一行
gnome-session &   #添加这一行

保存退出即可正常连接!

做到这里,总算是大功告成了,接下来你可以用http://IP:port的方式来WEB登录比如说

http://IP:5801,也可以在vncviewer里用IP:1这种来登录。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值