帮助在登录屏幕上在远程 Fedora Linux 计算机上使用 VNC

帮助在登录屏幕上在远程 Fedora Linux 计算机上使用 VNC

我有一台运行 Fedora 29 / gnome 的 Linux 机器。我总是在工作时保持其登录状态,这样当我回到家时,我可以通过 VNC 远程连接到它并继续工作。

在以前的 Fedora(我认为是 16)中,我在网上找到了有关如何在登录屏幕上启动 x11vnc 的信息,这样如果出现电源故障/崩溃/等情况,我可以重新启动计算机并通过 VNC 查看登录屏幕。那是在 systemd 之前的时代。

我还没有找到在 Fedora 29 上做到这一点的方法。尽管 x11vnc 在工作中登录后就会运行,但我找不到允许我通过 VNC 远程登录的神奇药水。现在我全职在家工作,我无法启动即使在注销后仍保留的会话。我必须尝试找到正在工作的人员,并向他们解释如何到达机器并向他们提供我的密码以运行 VNC 会话(是的,VNC 受密码保护)。

有谁知道如何设置 Fedora 29 / gnome 以从登录屏幕启动?如果缺少这一点,有没有办法通过 telnet/ssh 导致这种情况发生?通过 ssh 建立隧道似乎不是一个可行的选择,因为我在公司配置的笔记本电脑上运行 Win10。

这是/usr/lib/systemd/system/x11vnc.service:

[Unit]
Description=X11vnc
After=graphical.target

[Service]
Type=forking
ExecStart=/root/X11vnc_init
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=X11VNC
SyslogFacility=local5
SyslogLevel=debug
[Install]
WantedBy=graphical.target

...这是 /root/X11vnc_init:

#!/usr/bin/perl

if($ARGV[0] eq "stop"){system("killall -9 x11vnc"); exit 0;}
$DM="";
$LIGHT=`pgrep -x lightdm`; chomp $LIGHT;
if($LIGHT){
 $DM="lightdm"; 
 print "Found Lightdm Display manager\n";
 goto nextstep;
}
$KDM=`pgrep -x kdm`; chomp $KDM;
if($KDM){
 $DM="kdm";
 print "Found KDM Display manager\n";
 goto nextstep;
}
$GDM=`pgrep -x gdm`; chomp $GDM;
if($GDM){
 $DM="gdm";
 $dm=`ps ax |grep gdm |grep \\\\-auth |grep -v grep`;chomp $dm;
 ($junk1,$junk2)=split(/-auth /,$dm);
 ($junk3,$junk4)=split(/\/gdm\/Xauthority /,$junk2);
 $authfile="$junk3/gdm/Xauthority";
 print "Found GDM Display manager with authfile $authfile\n";
 goto nextstep;
}
$XDM=`pgrep -x xdm`; chomp $XDM;
if($XDM){
 $dm=`ps ax |grep xdm |grep authdir |grep -v grep`; chomp $dm;
 ($a,$filename)=split(/authdir\/authfiles\//,$dm);
 $authfile="/var/lib/xdm/authdir/authfiles/$filename";
 $DM="xdm";
 print "Found XDM Display manager with authfile $authfile\n";
 goto nextstep;
}
$SDDM=`pgrep -x sddm`; chomp $SDDM;
if($SDDM){
 $dm=`ps ax |grep sddm |grep var/run |grep -v grep`; chomp $dm;
 ($junk1,$junk2)=split(/-background/,$dm);
 ($junk3,$junk4)=split(/var\/run\/sddm\//,$junk1);
 $filename="/var/run/sddm/$junk4";
 $authfile="$filename";
 $DM="sddm";
 print "Found SDDM Display manager with authfile $authfile\n";
 goto nextstep;
}
nextstep:
if($DM eq "gdm"){$AUTH="-auth $authfile";}
if($DM eq "lightdm"){ $AUTH="-auth /var/run/lightdm/root/:0 ";}
if($DM eq "kdm" ){ $AUTH="-auth guess ";}
if($DM eq "xdm" || $DM eq "sddm"){$AUTH="-auth $authfile ";}
if(!$DM){
 print "NO Compatible dm found\n";
 exit 0;
}
my $pid = fork();
$XCMD="/usr/bin/x11vnc \
-rfbauth /root/x11vncpasswd \
-nap -many -norepeat 5 -alwaysshared -dontdisconnect \
-shared -nolookup \
$AUTH \
-rfbport 5900 -no6 -xkb -display :0 &";
$XCMD=~s/\n/ /gm;
open tmpsh,">/tmp/tmpvnc.sh";
print tmpsh "#!/bin/bash
sleep 10;
$XCMD
";
close tmpsh;
system("chmod 755 /tmp/tmpvnc.sh");
system("/tmp/tmpvnc.sh &");
exit 0;

谢谢,

马克

相关内容