Ubuntu – How to start the teamviewer service before login

remote desktopteamviewer

Suppose that there are two pc :pc-A and pc-B,both of them installed teamviewer(version 15.13.6).
First i boot pc-A,pc-B,no name and password inputted in pc-A,instead name and password inputted in pc-B,i login pc-B,the below is a screenshot for pc-A.
enter image description here

At this time , i can't input name and password in pc-A from pc-B via teamviewer,because that teamviewer service have not started in pc-A.

I want to set teamviewer service started before login pc-A.
Here is my try:

sudo vim /etc/systemd/system/remote-desktop.service    
[Unit]    
Description=remote-desktop
After=network.target
    
[Service]
Type=oneshot
ExecStart=/opt/teamviewer/tv_bin/script/teamviewer
KillMode=process

    
[Install]
WantedBy=multi-user.target

sudo systemctl reload remote-desktop.service
sudo systemctl enable remote-desktop.service

The remote-desktop.service can't be started at boot time until login.

● remote-desktop.service - remote-desktop
   Loaded: loaded (/etc/systemd/system/remote-desktop.service; enabled; vendor preset: enabled)
   Active: failed (Result: signal) since Sat 2021-01-23 16:33:58 CST; 3min 3s ago
  Process: 871 ExecStart=/opt/teamviewer/tv_bin/script/teamviewer (code=killed, signal=ABRT)
 Main PID: 871 (code=killed, signal=ABRT)
      CPU: 922ms

Jan 23 16:33:33  systemd[1]: Started remote-desktop.
Jan 23 16:33:36  teamviewer[871]: Init...
Jan 23 16:33:37  teamviewer[871]: xprop:  unable to open display ''
Jan 23 16:33:37  teamviewer[871]: CheckCPU: SSE2 support: yes
Jan 23 16:33:37  teamviewer[871]: Checking setup...
Jan 23 16:33:37  teamviewer[871]: Launching TeamViewer ...
Jan 23 16:33:37  teamviewer[871]: Launching TeamViewer GUI ...
Jan 23 16:33:58  systemd[1]: remote-desktop.service: Main process exited, code=killed, status=6/ABRT
Jan 23 16:33:58  systemd[1]: remote-desktop.service: Unit entered failed state.
Jan 23 16:33:58  systemd[1]: remote-desktop.service: Failed with result 'signal'.

Reboot pc-A and test, the name and password still can't input from pc-B via teamviewer.
And it is no use to set something in teamviewer's option.
enter image description here

My teamvierwer is the free version,there is no option such as Full access control when a partner is connecting to the Windows logon screen in my version,maybe you can introduce some other free remote control software (important:pay no money ) which can start before logoning the login screen .I accept it as a solution too when you have done,give the 500 bounty point.
Sum up:after remotely waking my pc,how can input account name and passwrod remotely,i can't do it with teamviewer.

How to fix it?

Best Answer

After trying and investigating the situation you have described in your post, the issue seems to be that this version of TeamViewer is unable to start an X server session which is needed for TeamViewer to work.

So you can enable automatic login on pc-A and it will work. Have a look at Automated login and screen lock If you need privacy and want the screen locked.

However, you do need to enable Start TeamViewer with system and set Personal Password under options in TeamViewer on pc-A then reboot first for that to work.


An alternative solution to remotely login and start X server session for TeamViewer to work is to install xrdp on pc-A like so:

sudo apt install xrdp

Then, make sure the xrdp service is enabled and started ( it usually is ).

After that from pc-B run remmina like so:

remmina

Then, enter the pc-A's IP in the remmina GUI and press Enter

remmina is most likely already installed on your system but if you need, install it like so:

sudo apt install remmina

Notice:

You can connect to xrdp by IP / Host-name only and if the two PCs are not on the same local network, you might find free dynamic DNS services like no-ip and others helpful.

Related Question