TransWikia.com

Help with using VNC on remote Fedora Linux machine at login screen

Unix & Linux Asked on October 31, 2021

I have a linux machine at work running Fedora 29 / gnome. I always leave it logged on at work so that when I get home I can remote VNC to it and keep working.

In previous Fedora’s (16 I think) I found info on the web on how to have x11vnc start on the login screen so that if there was a power fail / crash / etc I could restart the machine and see the login screen via VNC. This was in the pre-systemd days.

I haven’t found a way to do this with Fedora 29. Although x11vnc is running once there is a login at work I can’t find the magic potion that will allow me to login remotely via VNC. Now that I’m working at home full time I have no way to start a session that will remain even after logging off. I have to try to find someone physically at work and explain how to get to the machine and give them my password to get a VNC session running (Yes, VNC is password protected).

Does anyone out there know how to setup Fedora 29 / gnome to start with the login screen? Lacking that, is there a way to cause this to happen via telnet/ssh? Tunneling through ssh doesn’t seem to be a viable option since I’m running Win10 on a company configured laptop.

Here’s /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

…and here’s /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 managern";
 goto nextstep;
}
$KDM=`pgrep -x kdm`; chomp $KDM;
if($KDM){
 $DM="kdm";
 print "Found KDM Display managern";
 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 $authfilen";
 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 $authfilen";
 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 $authfilen";
 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 foundn";
 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;

Thanks,

Marc

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP