Arch 계열 EndeavourOS + Xfce 씁니다.
제가 예전에 xrdp 관련해서 요런 도움을 받았던 일이 있는데요:
https://www.clien.net/service/board/cm_linux/17801247CLIEN
그때는 일단 되는 거에 만족했는데, 한 가지 마음에 안 드는 게 있습니다.
xrdp 접속하면 Xfce 세션이 새로 생성되어서 로그인됩니다.
챗GPT 선생과 상담하면서 별별 짓을 다 해봤는데 죄다 실패하네요.
한 가지 의심스러운 건, xrdp 프로세스가 root에 의해 구동되는데 챗GPT가 알려주는 별별 짓을 다해도 로그인 아이디로 구동되지 않네요.
뭐가 문제일까요?
/etc/xrdp/startwm.sh :
pre_start()
{
if [ -r /etc/profile ]; then
. /etc/profile
fi
if [ -r ~/.bash_profile ]; then
. ~/.bash_profile
else
if [ -r ~/.bash_login ]; then
. ~/.bash_login
else
if [ -r ~/.profile ]; then
. ~/.profile
fi
fi
fi
return 0
}
post_start()
{
if [ -r ~/.bash_logout ]; then
. ~/.bash_logout
fi
return 0
}
#start the window manager
wm_start()
{
if [ -r /etc/locale.conf ]; then
. /etc/locale.conf
export LANG LANGUAGE
fi
# arch user
if [ -r ~/.xinitrc ]; then
pre_start
. ~/.xinitrc
post_start
exit 0
fi
Explicitly start Xfce
exec startxfce4
# arch
if [ -r /etc/X11/xinit/xinitrc ]; then
pre_start
. /etc/X11/xinit/xinitrc
post_start
exit 0
fi
pre_start
xterm
post_start
}
wm_start
exit 1
/etc/X11/Xwrapper.config :
allowed_users = anybody
ls -l ~/.Xauthority results:
-rw------- 1 woncheol woncheol 147 1월 12일 14:07 /home/woncheol/.Xauthority
'ps aux | grep xrdp' results:
root 555 0.0 0.0 15696 2032 ? S 14:24 0:00 /usr/bin/xrdp-sesman
root 570 0.0 0.0 23400 2652 ? S 14:24 0:00 /usr/bin/xrdp
sudo tail -f /var/log/xrdp.log
[20240112-15:13:12] [INFO ] address [0.0.0.0] port [3389] mode 1
[20240112-15:13:13] [INFO ] listening to port 3389 on 0.0.0.0
[20240112-15:13:13] [INFO ] xrdp_listen_pp done
[20240112-15:13:15] [INFO ] starting xrdp with pid 1410
[20240112-15:13:15] [INFO ] address [0.0.0.0] port [3389] mode 1
[20240112-15:13:15] [INFO ] listening to port 3389 on 0.0.0.0
[20240112-15:13:15] [INFO ] xrdp_listen_pp done
sudo tail -f /var/log/xrdp-sesman.log
[20240112-15:13:12] [INFO ] starting xrdp-sesman with pid 1407
파일에 아래 문구가 들어가야 할 듯 하고요.
needs_root_rights=no
세션 시작하는 명령은 보통은
/etc/xrdp/startwm.sh
파일에서 실행하지 않고, 대신
~/.xinitrc
파일을 사용자 홈에 만들어서 여기서 실행하는게 정석인 것 같습니다.
/etc/xrdp/startwm.sh 파일에는 ~/.xinitrc를 호출하도록 하는 내용이 들어가야겠죠.
(검색하면 예제가 많이 나올 듯 합니다)
세션실행 권한 자체가 root 가 아닌 사용자 아이디 권한으로 실행되도록 확실히 하니까요.
감사합니다. 이렇게 고쳤는데, 결과는 별 차이가 없네요;
/etc/xrdp/startwm.sh :
exec startxfce4 삭제
/etc/X11/Xwrapper.config :
needs_root_rights=no 추가
~/.xinitrc :
#!/bin/bash
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)
userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap
SESSION=${1:-xfce4-session}
# merge in defaults and keymaps
if [ -f $sysresources ]; then
xrdb -merge $sysresources
fi
if [ -f $sysmodmap ]; then
xmodmap $sysmodmap
fi
if [ -f "$userresources" ]; then
xrdb -merge "$userresources"
fi
if [ -f "$usermodmap" ]; then
xmodmap "$usermodmap"
fi
# start some nice programs
if [ -d /etc/X11/xinit/xinitrc.d ] ; then
for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
[ -x "$f" ] && . "$f"
done
unset f
fi
get_session(){
local dbus_args=(--sh-syntax)
case "$1" in
awesome) dbus_args+=(awesome) ;;
bspwm) dbus_args+=(bspwm-session) ;;
budgie) dbus_args+=(budgie-desktop) ;;
cinnamon) dbus_args+=(cinnamon-session) ;;
deepin) dbus_args+=(startdde) ;;
enlightenment) dbus_args+=(enlightenment_start) ;;
fluxbox) dbus_args+=(startfluxbox) ;;
gnome) dbus_args+=(gnome-session) ;;
i3|i3wm) dbus_args+=(i3 --shmlog-size 0) ;;
jwm) dbus_args+=(jwm) ;;
kde) dbus_args+=(startplasma-x11) ;;
lxde) dbus_args+=(startlxde) ;;
lxqt) dbus_args+=(lxqt-session) ;;
mate) dbus_args+=(mate-session) ;;
xfce) dbus_args+=(xfce4-session) ;;
openbox) dbus_args+=(openbox-session) ;;
*) dbus_args+=("$1") ;;
esac
echo "dbus-launch ${dbus_args[*]}"
}
exec $(get_session "$SESSION")
/etc/xrdp/sesman.ini
파일에서 어느 것으로 지정되어 있는지 확인해 보고
/etc/X11/xrdp/xorg_nvidia.conf
/etc/X11/xrdp/xorg.conf
중에서 지정된 파일의 내용을 살펴보고 확인해 봐야 할 것 같은데요.
사실 이 파일들은 자동생성되어 있을 것이므로 사용자가 건드릴 필요가 없는 부분일텐데...
원격접속 관련된 디바이스들이 정의되어 있고,
특히 사용되는 스크린도 정의되어 있기 때문에
스크린 부분을 확인해 보셔야 할 것 같아요.
제 경우에는 모니터가 달려있지 않은 헤드레스 컴퓨터에 접근하기 때문에
Virtual Display로 설정이 되어 있고, 스크린 넘버는 0로 지정되어 있어서
스크린이 고정되어 있어서
로그인할 때 마다 새로운 스크린에 새로운 세션이 뜨지는 않는 것으로 이해하고 있습니다.
로그인 할 때 마다 새로운 가상스크린으로 새롭게 세션이 시작된다면,
이 부분의 내용이 먹히고 있지 않다는 의미일 것 같기 때문에
어디서 그렇게 작동하는지를 추적하면 알아낼 수 있지 않을까 싶습니다.
/etc/xrdp/sesman.ini
[Globals]
ListenAddress=127.0.0.1
ListenPort=3350
EnableSSL=1
EnableUserWindowManager=true
UserWindowManager=startwm.sh
DefaultWindowManager=startwm.sh
ReconnectScript=reconnectwm.sh
[Security]
AllowRootLogin=true
MaxLoginRetry=4
TerminalServerUsers=tsusers
TerminalServerAdmins=tsadmins
AlwaysGroupCheck=false
RestrictOutboundClipboard=none
RestrictInboundClipboard=none
[Sessions]
X11DisplayOffset=10
MaxSessions=50
KillDisconnected=false
DisconnectedTimeLimit=0
IdleTimeLimit=0
Policy=Default
[Logging]
LogFile=xrdp-sesman.log
LogLevel=INFO
EnableSyslog=true
[LoggingPerLogger]
[Xorg]
param=Xorg
param=-config
param=xrdp/xorg.conf
param=-noreset
param=-nolisten
param=tcp
param=-logfile
param=.xorgxrdp.%s.log
[Xvnc]
param=Xvnc
param=-bs
param=-nolisten
param=tcp
param=-localhost
param=-dpi
param=96
[Chansrv]
FuseMountName=thinclient_drives
FileUmask=077
[ChansrvLogging]
LogLevel=INFO
EnableSyslog=true
[ChansrvLoggingPerLogger]
[SessionVariables]
PULSE_SCRIPT=/etc/xrdp/pulse/default.pa
없음
/etc/X11/xrdp/xorg.conf
Section "ServerLayout"
Identifier "X11 Server"
Screen "Screen (xrdpdev)"
InputDevice "xrdpMouse" "CorePointer"
InputDevice "xrdpKeyboard" "CoreKeyboard"
EndSection
Section "ServerFlags"
# This line prevents "ServerLayout" sections in xorg.conf.d files
# overriding the "X11 Server" layout (xrdp #1784)
Option "DefaultServerLayout" "X11 Server"
Option "DontVTSwitch" "on"
Option "AutoAddDevices" "off"
EndSection
Section "Module"
Load "dbe"
Load "ddc"
Load "extmod"
Load "glx"
Load "int10"
Load "record"
Load "vbe"
Load "xorgxrdp"
Load "fb"
EndSection
Section "InputDevice"
Identifier "xrdpKeyboard"
Driver "xrdpkeyb"
EndSection
Section "InputDevice"
Identifier "xrdpMouse"
Driver "xrdpmouse"
EndSection
Section "Monitor"
Identifier "Monitor"
Option "DPMS"
HorizSync 30-80
VertRefresh 60-75
ModeLine "1920x1080" 138.500 1920 1968 2000 2080 1080 1083 1088 1111 +hsync -vsync
ModeLine "1280x720" 74.25 1280 1720 1760 1980 720 725 730 750 +HSync +VSync
Modeline "1368x768" 72.25 1368 1416 1448 1528 768 771 781 790 +hsync -vsync
Modeline "1600x900" 119.00 1600 1696 1864 2128 900 901 904 932 -hsync +vsync
EndSection
Section "Device"
Identifier "Video Card (xrdpdev)"
Driver "xrdpdev"
Option "DRMDevice" "/dev/dri/renderD128"
Option "DRI3" "1"
EndSection
Section "Screen"
Identifier "Screen (xrdpdev)"
Device "Video Card (xrdpdev)"
Monitor "Monitor"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "640x480" "800x600" "1024x768" "1280x720" "1280x1024" "1600x900" "1920x1080"
EndSubSection
EndSection