丛思源 發表於 2024-7-11 14:54:00

麒麟操作系统配置vnc(root登录)

<p><span style="font-size: 16px">&nbsp;</span></p>
<p><span style="font-size: 16px">环境:</span><br><span style="font-size: 16px">Os:v2401.ky10 sp3</span></p>
<p><span style="font-size: 16px">1.安装vnc</span></p>
<p><span style="font-size: 16px">#dnf install tigervnc-server -y</span></p>
<p><span style="font-size: 16px">&nbsp;</span></p>
<p><span style="font-size: 16px">2.修改配置文件</span><br><span style="font-size: 16px">cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service</span></p>
<p><span style="font-size: 16px">&nbsp;</span></p>
<p><span style="font-size: 16px">vi /etc/systemd/system/vncserver@:1.service</span><br><span style="font-size: 16px">原来的:</span></p>
<div class="cnblogs_code">
<pre><span style="font-size: 16px"><span style="color: rgba(0, 0, 0, 1)">
Description</span>=<span style="color: rgba(0, 0, 0, 1)">Remote desktop service (VNC)
After</span>=<span style="color: rgba(0, 0, 0, 1)">syslog.target network.target


Type</span>=<span style="color: rgba(0, 0, 0, 1)">forking
WorkingDirectory</span>=/home/&lt;USER&gt;<span style="color: rgba(0, 0, 0, 1)">
User</span>=&lt;USER&gt;<span style="color: rgba(0, 0, 0, 1)">
Group</span>=&lt;USER&gt;<span style="color: rgba(0, 0, 0, 1)">

PIDFile</span>=/home/&lt;USER&gt;/.vnc/%H%<span style="color: rgba(0, 0, 0, 1)">i.pid

ExecStartPre</span>=/bin/sh -c <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">/usr/bin/vncserver -kill %i &gt; /dev/null 2&gt;&amp;1 || :</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
ExecStart</span>=/usr/bin/vncserver -autokill %<span style="color: rgba(0, 0, 0, 1)">i
ExecStop</span>=/usr/bin/vncserver -kill %<span style="color: rgba(0, 0, 0, 1)">i

Restart</span>=on-<span style="color: rgba(0, 0, 0, 1)">success
RestartSec</span>=<span style="color: rgba(128, 0, 128, 1)">15</span><span style="color: rgba(0, 0, 0, 1)">


WantedBy</span>=multi-user.target</span></pre>
</div>
<p><span style="font-size: 16px">&nbsp;</span></p>
<p><span style="font-size: 16px">修改为:</span></p>
<div class="cnblogs_code">
<pre><span style="font-size: 16px"><span style="color: rgba(0, 0, 0, 1)">
Description</span>=<span style="color: rgba(0, 0, 0, 1)">Remote desktop service (VNC)
After</span>=<span style="color: rgba(0, 0, 0, 1)">syslog.target network.target


Type</span>=<span style="color: rgba(0, 0, 0, 1)">forking
WorkingDirectory</span>=/<span style="color: rgba(0, 0, 0, 1)">root
User</span>=<span style="color: rgba(0, 0, 0, 1)">root
Group</span>=<span style="color: rgba(0, 0, 0, 1)">root

PIDFile</span>=/root/.vnc/%H%<span style="color: rgba(0, 0, 0, 1)">i.pid

ExecStartPre</span>=/bin/sh -c <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">/usr/bin/vncserver -kill %i &gt; /dev/null 2&gt;&amp;1 || :</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
ExecStart</span>=/usr/bin/vncserver -autokill %<span style="color: rgba(0, 0, 0, 1)">i
ExecStop</span>=/usr/bin/vncserver -kill %<span style="color: rgba(0, 0, 0, 1)">i

Restart</span>=on-<span style="color: rgba(0, 0, 0, 1)">success
RestartSec</span>=<span style="color: rgba(128, 0, 128, 1)">15</span><span style="color: rgba(0, 0, 0, 1)">


WantedBy</span>=multi-user.target</span></pre>
</div>
<p>&nbsp;</p>
<p><span style="font-size: 16px">4.关闭防火墙</span></p>
<p><span style="font-size: 16px"><em id="__mceDel">systemctl status firewalld.service<br>systemctl stop firewalld.service<br>systemctl disable firewalld.service<br>vi /etc/selinux/config<br>set "SELINUX=disabled" and comment the rest lines.</em></span></p>
<p><span style="font-size: 16px">&nbsp;</span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-size: 16px">4.加载配置</span><br><span style="font-size: 16px"># systemctl daemon-reload</span></p>
<p><span style="font-size: 16px">&nbsp;</span></p>
<p><span style="font-size: 16px">5.设置vnc密码</span><br><span style="font-size: 16px">su - oracle</span><br><span style="font-size: 16px">$ vncpasswd</span><br><span style="font-size: 16px">我这里设置密码为:Aub*axl3</span></p>
<p><span style="font-size: 16px">&nbsp;</span></p>
<p><span style="font-size: 16px">6.启动</span><br><span style="font-size: 16px">systemctl start vncserver@:1.service</span></p>
<p><span style="font-size: 16px">&nbsp;</span></p>
<p><span style="font-size: 16px">7.查看端口</span></p>
<div class="cnblogs_code">
<pre><span style="font-size: 16px"># ss -nlp|grep <span style="color: rgba(128, 0, 128, 1)">5901</span><span style="color: rgba(0, 0, 0, 1)">
tcp                LISTEN            </span><span style="color: rgba(128, 0, 128, 1)">0</span>                  <span style="color: rgba(128, 0, 128, 1)">5</span>                                                                  <span style="color: rgba(128, 0, 128, 1)">0.0</span>.<span style="color: rgba(128, 0, 128, 1)">0.0</span>:<span style="color: rgba(128, 0, 128, 1)">5901</span>             <span style="color: rgba(128, 0, 128, 1)">0.0</span>.<span style="color: rgba(128, 0, 128, 1)">0.0</span>:*         users:((<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">Xvnc</span><span style="color: rgba(128, 0, 0, 1)">"</span>,pid=<span style="color: rgba(128, 0, 128, 1)">29774</span>,fd=<span style="color: rgba(128, 0, 128, 1)">6</span><span style="color: rgba(0, 0, 0, 1)">))                                       
tcp                LISTEN            </span><span style="color: rgba(128, 0, 128, 1)">0</span>                  <span style="color: rgba(128, 0, 128, 1)">5</span>                                                                     [::]:<span style="color: rgba(128, 0, 128, 1)">5901</span>                [::]:*         users:((<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">Xvnc</span><span style="color: rgba(128, 0, 0, 1)">"</span>,pid=<span style="color: rgba(128, 0, 128, 1)">29774</span>,fd=<span style="color: rgba(128, 0, 128, 1)">7</span><span style="color: rgba(0, 0, 0, 1)">))                                       
# </span></pre>
</div>
<p><span style="font-size: 16px">&nbsp;</span></p>
<p><span style="font-size: 16px">8.普通用户的登录配置</span></p>
<div class="cnblogs_code">
<pre><span style="font-size: 16px"><span style="color: rgba(0, 0, 0, 1)">
Description</span>=<span style="color: rgba(0, 0, 0, 1)">Remote desktop service (VNC)
After</span>=<span style="color: rgba(0, 0, 0, 1)">syslog.target network.target


Type</span>=<span style="color: rgba(0, 0, 0, 1)">forking
WorkingDirectory</span>=/home/<span style="color: rgba(0, 0, 0, 1)">oracle
<span style="color: rgba(255, 0, 0, 1)">User</span></span><span style="color: rgba(255, 0, 0, 1)">=oracle
Group=oinstall</span><span style="color: rgba(0, 0, 0, 1)">

PIDFile</span>=/home/oracle/.vnc/%H%<span style="color: rgba(0, 0, 0, 1)">i.pid

ExecStartPre</span>=/bin/sh -c <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">/usr/bin/vncserver -kill %i &gt; /dev/null 2&gt;&amp;1 || :</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
ExecStart</span>=/usr/bin/vncserver -autokill %<span style="color: rgba(0, 0, 0, 1)">i
ExecStop</span>=/usr/bin/vncserver -kill %<span style="color: rgba(0, 0, 0, 1)">i

Restart</span>=on-<span style="color: rgba(0, 0, 0, 1)">success
RestartSec</span>=<span style="color: rgba(128, 0, 128, 1)">15</span><span style="color: rgba(0, 0, 0, 1)">


WantedBy</span>=multi-user.target</span></pre>
</div>
<p><span style="font-size: 16px">&nbsp;</span></p>
<p><span style="font-size: 16px">说明:</span></p>
<p><span style="font-size: 16px">发现麒麟系统的环境变量需要放在.bashrc这个文件才生效,放在 .bash_profile通过vnc登录不生效</span></p>
<div class="cnblogs_code">
<pre><span style="font-size: 16px">$ more .bashrc
# Source </span><span style="color: rgba(0, 0, 255, 1)">default</span><span style="color: rgba(0, 0, 0, 1)"> setting
[ </span>-f /etc/bashrc ] &amp;&amp; . /etc/<span style="color: rgba(0, 0, 0, 1)">bashrc

# User environment PATH
export PATH

export EDITOR</span>=<span style="color: rgba(0, 0, 0, 1)">vi
export ORACLE_SID</span>=<span style="color: rgba(0, 0, 0, 1)">ora19c
export ORACLE_BASE</span>=/u01/app/<span style="color: rgba(0, 0, 0, 1)">oracle
export ORACLE_HOME</span>=$ORACLE_BASE/product/<span style="color: rgba(128, 0, 128, 1)">19.3</span>.<span style="color: rgba(128, 0, 128, 1)">0.0</span>/<span style="color: rgba(0, 0, 0, 1)">db_1
export LD_LIBRARY_PATH</span>=$ORACLE_HOME/lib:/lib:/usr/<span style="color: rgba(0, 0, 0, 1)">lib
export PATH</span>=$ORACLE_HOME/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:/<span style="color: rgba(0, 0, 0, 1)">bin
export CV_ASSUME_DISTID</span>=<span style="color: rgba(0, 0, 0, 1)">OEL7
umask </span><span style="color: rgba(128, 0, 128, 1)">022</span></span></pre>
</div>
<p><span style="font-size: 16px">&nbsp;</span></p><br><br>
来源:https://www.cnblogs.com/hxlasky/p/18296220
頁: [1]
查看完整版本: 麒麟操作系统配置vnc(root登录)