喏只毅仔 發表於 2019-7-14 11:35:00

Windows下通过VNC远程访问Linux服务器,并实现可视化

<h1 id="前言">前言</h1>
<p>最近因部门需要,老大想让我在公司Linux服务器上弄个Oracle,以用作部门测试环境的数据库服务器,经过一番折腾后,成功完成了任务。因公司Linux服务器是无图形界面的,本人接触Linux不多,为了更方便的操作,特地学习了下如何在Windows环境下通过VNC来访问Linux,使其能在图形界面上操作。</p>
<h1 id="securecrt连接linux">SecureCRT连接Linux</h1>
<p>首先,我们需要能够正常连接到服务器。在这里,我选择通过SecureCRT远程连接到Linux服务器(安装操作过程很简单,在这里就不详细说明了),连接之后,可直接进行类似Linux终端的操作。连接后的界面如下:</p>
<p><img src="https://upload-images.jianshu.io/upload_images/16853007-96fb3ef14b48d180.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="" loading="lazy"></p>
<h1 id="winscp上传文件">WinSCP上传文件</h1>
<p>有时我们需要在Windows下远程上传文件到Linux服务器上,方法也有很多种。在这里,我是通过WinSCP,将Windows下的文件上传到Linux服务器上。WinSCP的安装操作过程很简单,在下图中,左侧是Windows本地的文件,右侧是Linux上的文件,我们只需简单进行拖拽,便完成实现文件上传的功能。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/16853007-76bcc7f7f4e9fd2c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="" loading="lazy"></p>
<p>(WinSCP下载链接:https://winscp.net/eng/download.php)</p>
<h1 id="vnc的安装">VNC的安装</h1>
<p>VNC主要包括VNC Viewer和VNC Server两部分,为了能够在图形界面上进行操作(公司Linux是无图形界面的),我在这里通过VNC来实现。</p>
<h3 id="1windows上安装vnc-viewer">1.Windows上安装VNC Viewer</h3>
<p>VNC Viewer是客户端的应用程序,我们主要使用它来建立连接并实现远程控制,当然,它也是免费开源的,安装起来也很容易。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/16853007-fb0114c6b0b3636e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="" loading="lazy"></p>
<p>(VNC Viewer下载链接:https://www.realvnc.com/en/connect/download/viewer/)</p>
<h3 id="2linux上安装vnc-server">2.Linux上安装VNC Server</h3>
<p>VNC Server是服务端的应用程序,我们目前需要做的就是使VNC Viewer成功连接上VNC Viewer,这样便可以访问Linux,并实现可视化。</p>
<p>检查Linux是否安装了VNC服务,输入命令:<strong>rpm -qa | grep vnc</strong> ,如已安装,则会显示已安装的信息。</p>
<p>如果未安装的话,安装VNC Server时,若Linux服务器可正常联网,那么我们可以很方便的通过 <strong>yum</strong> 命令来安装,在终端输入命令:<strong>yum install tigervnc-server</strong> ;若无法在Linux下联网,那么我们可以将VNC Server的离线安装包通过上传到服务器,再进行安装。</p>
<p>因为Linux环境无法联网,我的做法是,在自己电脑的CentOS下,通过 <strong>yum</strong> 命令的 <strong>downloadonly</strong> 方式,先下载离线安装包,再上传至公司Linux服务器,最后通过 <strong>rpm</strong> 命令进行安装。</p>
<p>下载离线安装包命令:<strong>yum -y install --downloadonly --downloaddir=./temp1 tigervnc-server</strong> (./temp1指下载存放路径)</p>
<p><img src="https://upload-images.jianshu.io/upload_images/16853007-4b373b13051fc663.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="" loading="lazy"></p>
<p>Linux上手动安装命令:<strong>rpm -ivh --force --nodeps *.rpm</strong>(强制安装当前目录下的所有 <strong>.rpm</strong> 文件)</p>
<p><img src="https://upload-images.jianshu.io/upload_images/16853007-846e7318437382c0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="" loading="lazy"></p>
<p>安装完成之后,需要开启vncserver服务,输入命令:<strong>vncserver</strong> ,第一次启动会要求输入密码,按提示操作即可。密码设置后,会产生如下信息:</p>
<p><img src="https://upload-images.jianshu.io/upload_images/16853007-e63cce48e506b890.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="" loading="lazy"></p>
<p>在此,我们需要记住生成的桌面号(这里生成的桌面号是 <strong>:1</strong> ),因为接下来我们通过VNC Viewer访问VNC Server时将会用到。</p>
<h3 id="3vnc-viewer建立连接">3.VNC Viewer建立连接</h3>
<p><img src="https://upload-images.jianshu.io/upload_images/16853007-b5ce09af27598110.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="" loading="lazy"></p>
<p>我们需要输入VNC Server和Name,假如Linux服务器的ip地址是10.201.10.10,那么VNC Server输入10.201.10.10:1(<strong>1</strong>就是上一步骤中分配的桌面号),至于Name,这个就是我们准备给连接起的名字。</p>
<p>建立连接后,可能会遇到如下错误:</p>
<p><img src="https://upload-images.jianshu.io/upload_images/16853007-5943d6138c5cb443.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="" loading="lazy"></p>
<p>这里可能是因为Linux开启了防火墙,会阻止连接过程,解决方法就是我们手动开启相应的端口,以分配的桌面号"1"为例,开启相应端口的命令如下:</p>
<pre><code># iptables -I INPUT -p tcp --dport 5901 -j ACCEPT
# iptables -I INPUT -p tcp --dport 5801 -j ACCEPT
</code></pre>
<p><img src="https://upload-images.jianshu.io/upload_images/16853007-2381f444016c84cf.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="" loading="lazy"></p>
<p>解决这个问题后,再次建立连接,可以发现已经能够访问,并能够在图形界面上操作了。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/16853007-e6b7f62417ff9484.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="" loading="lazy"></p>
<p>OK,通过以上步骤,我们便可以更方便的在图形界面下操作Linux,比如我们可以通过启动 xhost + ,在图形化界面下完成oracle的安装。</p>
<p><strong>如有错误,欢迎指出!</strong></p>


</div>
<div id="MySignature" role="contentinfo">
    <div color="blue">作者:<font color="#5D1F88">wintest</font></div>
<div>出处:<font color="#5D1F88">https://www.cnblogs.com/wintest</font></div>
<div>本文版权归作者和博客园共有,欢迎转载,但必须在文章页面明显位置给出原文链接,并保留此段声明,否则保留追究法律责任的权利。 </div><br><br>
来源:https://www.cnblogs.com/wintest/p/11183517.html
頁: [1]
查看完整版本: Windows下通过VNC远程访问Linux服务器,并实现可视化