6

I'm working remotely via SSH connection and need to use some GUI applications on the remote machine. I do not have an X-Server for X forwarding on my local machine, but a RDP client.

Can I somehow enable RDP via command line?

Usually one would do this in the Settings app in the "Sharing" tab.

slarag
  • 237

3 Answers3

4

Gnome Remote Desktop (RDP/VNC on Ubuntu 22.04 and other recent versions) can be enabled through command line by using the grdctl command.

The command line parameters are documented in the man pages of the cli tool, e.g. here.

When using it through SSH, I initially had the problem that

  • it was not working with sudo
  • using the tool without sudo blocked indefinetly because it was waiting for a graphical admin prompte on the desktop of the remote host.

The only workaround I found so far was to initially configure RDP direclty on the remote host first.

slarag
  • 237
4

Install winpr-makecert:

sudo apt install winpr-utils 

or winpr-makecert3:

sudo apt install winpr3-utils 

For session with monitor:

Login as user (not su, it needs dbus session and gnome keyring running). Then:

RDP_USER="${USER}"
RDP_PASS="12345678"

winpr-makecert -silent -rdp -path ~/.local/share/gnome-remote-desktop/ rdp-tls grdctl rdp set-tls-key ~/.local/share/gnome-remote-desktop/rdp-tls.key grdctl rdp set-tls-cert ~/.local/share/gnome-remote-desktop/rdp-tls.crt grdctl rdp set-credentials "${RDP_USER}" "${RDP_PASS}" grdctl rdp enable grdctl rdp disable-view-only

For headless sessions

RDP_USER="${USER}"
RDP_PASS="12345678"

sudo -u gnome-remote-desktop winpr-makecert -silent -rdp -path ~gnome-remote-desktop rdp-tls sudo grdctl --system rdp set-tls-key ~gnome-remote-desktop/rdp-tls.key sudo grdctl --system rdp set-tls-cert ~gnome-remote-desktop/rdp-tls.crt sudo grdctl --system rdp enable sudo grdctl --system rdp set-credentials "${RDP_USER}" "${RDP_PASS}" sudo systemctl --now enable gnome-remote-desktop.service

eri
  • 245
-1

You could install, then start x11vnc on the remote machine, then use a VNC client to connect. If you require RDP specifically, then this answer (which also uses x11vnc, but with the xrdp connector) is your best bet.

However, if VNC is adequate, then it's pretty simple. Note that the three steps I list here do not provide any security! If the remote machine can be accessed by anyone other than yourself, make sure to man x11vnc and put a password on the remote x11vnc session.

  1. On the remote machine, install x11vnc

sudo apt install x11vnc

  1. On the remote machine, start x11vnc

x11vnc -forever

  1. On your machine, connect to the remote machine using your VNC client (e.g. Remmina)

Once you're finished, hit CTRL-C on your remote machine to exit x11vnc.

If you intend to use x11vnc more commonly, as I stated above, I recommend setting a password with x11vnc -usepw, and then examining some of the more advanced options it offers with man x11vnc. It's a powerful tool.

Scaine
  • 11,229