xrdp 到 Ubuntu 加载不同的会话

xrdp 到 Ubuntu 加载不同的会话

当我使用我的 PC A 登录运行 Ubuntu 的服务器的远程桌面,运行某些程序(例如 MATLAB),关闭连接并重新登录服务器时,MATLAB 仍在运行。

但是,如果我使用我的 PC B 重新登录服务器,它似乎是一个新会话,并且看不到 MATLAB 窗口。但top显示 MATLAB 正在运行。

我怎样才能登录到使用 PC A 开始的同一会话?

答案1

理论上,有两种方法可以做到这一点:

  1. [来源]编辑 xrdp.ini 以添加自定义local login

    • 确保已安装 xrdp 和 vino

      sudo apt-get install xrdp vino
      
    • 编辑/etc/xrdp/xrdp.ini

      sudo gedit /etc/xrdp/xrdp.ini
      
    • 复制xrdp1块并将其编号更改为 ini 文件中尚未包含的其他内容。基本上,这里的数字决定了下拉顺序。添加此

      [xrdp1] 
      name=MyLocalLogin 
      lib=libvnc.so 
      username= password=ask
      ip=127.0.0.1 
      port=5900
      
    • 现在只需尝试 rdp 并选择您的自定义会话MyLocalLogin

  2. [来源]我还没有尝试过。这看起来有点麻烦,因为它需要修改并重新编译 xrdp 源。

    • 安装所需的基本东西。

      sudo apt-get install autoconf libtool libpam0g-dev libx11-dev libxfixes-dev libssl-dev
      sudo apt-get install gnome-session-fallback
      echo  ”gnome-session --session=gnome-fallback” > ~/.xsession   
      sudo apt-get install x11vnc
      
    • 从以下位置下载 xrdp 源代码这里。现在将其解压到任意位置,我们将其命名为 root。转到 root/xrdp-master 并:

      sudo ./bootstrap
      sudo ./configure
      sudo make
      sudo make install
      
    • 现在我们需要配置我们的系统以便使用 X11Vnc 包的 xrdp,并在 Ubuntu 计算机重新启动时自动启动 xrdp 服务。

      sudo apt-get install xrdp 
      sudo apt-get remove xrdp
      sudo mv startwm.sh startwm.sh.backup 
      sudo ln -s /etc/X11/Xsession /etc/xrdp/startwm.sh 
      sudo mkdir /usr/share/doc/xrdp 
      sudo cp /etc/xrdp/rsakeys.ini /usr/share/doc/xrdp/rsakeys.ini
      
    • 现在我们需要更新/etc/init.d/xrdp。只需将修改后的 xrdp 脚本文件的内容复制到 /etc/init.d/xrdp 中即可

      <-------   Begin of the Script -------->
      
      #!/bin/sh -e
      #
      # start/stop xrdp and sesman daemons
      #
      ### BEGIN INIT INFO
      # Provides:          xrdp
      # Required-Start:    $network $remote_fs
      # Required-Stop:     $network $remote_fs
      # Default-Start:     2 3 4 5
      # Default-Stop:      0 1 6
      # Short-Description: Start xrdp and sesman daemons
      # Description:       XRDP uses the Remote Desktop Protocol to present a
      #                    graphical login to a remote client allowing connection
      #                    to a VNC server or another RDP server.
      ### END INIT INFO
      
      PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
      DAEMON=/usr/local/sbin/xrdp
      PIDDIR=/var/run
      SESMAN_START=yes
      USERID=xrdp
      RSAKEYS=/etc/xrdp/rsakeys.ini
      NAME=xrdp
      DESC="Remote Desktop Protocol server"
      
      test -x $DAEMON || exit 0
      
      . /lib/lsb/init-functions
      
      check_root()  {
          if [ "$(id -u)" != "0" ]; then
              log_failure_msg "You must be root to start, stop or restart $NAME."
              exit 4
          fi
      }
      
      if [ -r /etc/default/$NAME ]; then
         . /etc/default/$NAME
      fi
      
      # Tasks that can only be run as root
      if [ "$(id -u)" = "0" ]; then
          # Check for pid dir
          if [ ! -d $PIDDIR ] ; then
              mkdir $PIDDIR
          fi
          chown $USERID:$USERID $PIDDIR
      
          # Check for rsa key 
          if [ ! -f $RSAKEYS ] || cmp $RSAKEYS /usr/share/doc/xrdp/rsakeys.ini > /dev/null; then
              log_action_begin_msg "Generating xrdp RSA keys..."
              (umask 077 ; xrdp-keygen xrdp $RSAKEYS)
              chown $USERID:$USERID $RSAKEYS
              if [ ! -f $RSAKEYS ] ; then
                  log_action_end_msg 1 "could not create $RSAKEYS"
                  exit 1
              fi
              log_action_end_msg 0 "done"
          fi
      fi
      
      case "$1" in
        start)
              check_root
              exitval=0
              log_daemon_msg "Starting $DESC " 
              if pidofproc -p $PIDDIR/$NAME.pid $DAEMON > /dev/null; then
                  log_progress_msg "$NAME apparently already running"
                  log_end_msg 0
                  exit 0
              fi
              log_progress_msg $NAME
              start-stop-daemon --start --quiet --oknodo  --pidfile $PIDDIR/$NAME.pid \
              --chuid $USERID:$USERID --exec $DAEMON
              exitval=$?
          if [ "$SESMAN_START" = "yes" ] ; then
                  log_progress_msg "sesman"
                  start-stop-daemon --start --quiet --oknodo --pidfile $PIDDIR/xrdp-sesman.pid \
                 --exec /usr/local/sbin/xrdp-sesman
                  value=$?
                  [ $value -gt 0 ] && exitval=$value
              fi
              # Make pidfile readables for all users (for status to work)
              [ -e $PIDDIR/xrdp-sesman.pid ] && chmod 0644 $PIDDIR/xrdp-sesman.pid
              [ -e $PIDDIR/$NAME.pid ] && chmod 0644 $PIDDIR/$NAME.pid
              # Note: Unfortunately, xrdp currently takes too long to create
              # the pidffile unless properly patched
              log_end_msg $exitval
          ;;
        stop)
              check_root
          [ -n "$XRDP_UPGRADE" -a "$RESTART_ON_UPGRADE" = "no" ] && {
              echo "Upgrade in progress, no restart of xrdp."
              exit 0
          }
              exitval=0
              log_daemon_msg "Stopping RDP Session manager " 
              log_progress_msg "sesman"
              if pidofproc -p  $PIDDIR/xrdp-sesman.pid /usr/local/sbin/xrdp-sesman  > /dev/null; then
                  start-stop-daemon --stop --quiet --oknodo --pidfile $PIDDIR/xrdp-sesman.pid \
                      --chuid $USERID:$USERID --exec /usr/local/sbin/xrdp-sesman
                  exitval=$?
              else
                  log_progress_msg "apparently not running"
              fi
              log_progress_msg $NAME
              if pidofproc -p  $PIDDIR/$NAME.pid $DAEMON  > /dev/null; then
                  start-stop-daemon --stop --quiet --oknodo --pidfile $PIDDIR/$NAME.pid \
              --exec $DAEMON
                  value=$?
                  [ $value -gt 0 ] && exitval=$value
              else
                  log_progress_msg "apparently not running"
              fi
              log_end_msg $exitval
          ;;
        restart|force-reload)
              check_root
          $0 stop
              # Wait for things to settle down
              sleep 1
          $0 start
          ;;
        reload)
              log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
              log_warning_msg "cannot re-read the config file (use restart)."
              ;;
        status)
              exitval=0
              log_daemon_msg "Checking status of $DESC" "$NAME"
              if pidofproc -p  $PIDDIR/$NAME.pid $DAEMON  > /dev/null; then
                  log_progress_msg "running"
                  log_end_msg 0
              else
                  log_progress_msg "apparently not running"
                  log_end_msg 1 || true
                  exitval=1
              fi
          if [ "$SESMAN_START" = "yes" ] ; then
                  log_daemon_msg "Checking status of RDP Session Manager" "sesman"
                  if pidofproc -p  $PIDDIR/xrdp-sesman.pid /usr/local/sbin/xrdp-sesman  > /dev/null; then
                      log_progress_msg "running"
                      log_end_msg 0
                  else
                      log_progress_msg "apparently not running"
                      log_end_msg 1 || true
                      exitval=1
                  fi
              fi
              exit $exitval
              ;;
        *)
          N=/etc/init.d/$NAME
          echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
          exit 1
          ;;
      esac
      
      exit 0
      

相关内容