Skip to content

Instantly share code, notes, and snippets.

@imami
Last active May 8, 2024 00:52
Show Gist options
  • Save imami/4e8b187e7e1e6fc9510d907eb1a7a5b3 to your computer and use it in GitHub Desktop.
Save imami/4e8b187e7e1e6fc9510d907eb1a7a5b3 to your computer and use it in GitHub Desktop.
AnyDesk - How Enable Remote Access from ubuntu/debian terminal

###AnyDesk - How Enable Remote Access from ubuntu/debian terminal.

Note:

Here are the commands might be usefull in this purpose:

  • anydesk --get-status : To get current status of anydesk, which might be offlien,online or nothing.
  • anydesk --get-id : To get the ID that your system can be accessed by.
  • anydesk --service : To start anydesk service if not already running (for Linux).
  • anydesk --restart-service : To restart anydesk service
  • anydesk --stop-service : To stop anydesk service
  • sudo echo qazwsxedc | anydesk --set-password : to set password on anydesk (required to access from a remote system).

In case that your target machine is a kind of a Ubuntu or a Debian based one:

  1. echo -e "ad.security.allow_logon_token=true\nad.features.unattended=true" >> ~/.anydesk/user.conf
  2. sudo echo [your-custom-password] | anydesk --set-password
  3. sudo sed -i '' -e 's/# AutomaticLogin/AutomaticLogin/g' -e 's/#WaylandEnable/WaylandEnable/g' /etc/gdm3/custom.conf
  4. sudo reboot
  5. Drink your coffee, and wait until your system becomes up and accessible via ssh or terminal.
  6. Run anydesk --get-status , if its not online then run anydesk --service.
  7. Run anydesk --get-id && echo to get your desk id.
  8. Use your desk id in your Anydesk client, to access the remote system.

Github: github.com/imami , Twitter: @e_imami

@peter279k
Copy link

peter279k commented Sep 13, 2022

@amatteo78, it's possible to install the anydesk without GUI in Ubuntu. Please consider using the following installation steps:

root@ubuntu-s-4vcpu-8gb-amd-sgp1-01:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.6 LTS
Release:        18.04
Codename:       bionic
root@ubuntu-s-4vcpu-8gb-amd-sgp1-01:~# apt-get update
Get:1 http://mirrors.digitalocean.com/ubuntu bionic InRelease [242 kB]
Hit:2 https://repos-droplet.digitalocean.com/apt/droplet-agent main InRelease
Get:3 http://mirrors.digitalocean.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:4 http://mirrors.digitalocean.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:5 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:6 http://mirrors.digitalocean.com/ubuntu bionic-updates/main amd64 Packages [2730 kB]
Get:7 https://packages.clickhouse.com/deb stable InRelease [5536 B]
Get:8 https://packages.clickhouse.com/deb stable/main amd64 Packages [18.4 kB]
Fetched 3248 kB in 1s (3231 kB/s)
Reading package lists... Done
root@ubuntu-s-4vcpu-8gb-amd-sgp1-01:~# curl -fsSL https://keys.anydesk.com/repos/DEB-GPG-KEY|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/anydesk.gpg
root@ubuntu-s-4vcpu-8gb-amd-sgp1-01:~# echo "deb http://deb.anydesk.com/ all main" | sudo tee /etc/apt/sources.list.d/anydesk-stable.list
deb http://deb.anydesk.com/ all main
root@ubuntu-s-4vcpu-8gb-amd-sgp1-01:~# apt-get update
Get:1 http://mirrors.digitalocean.com/ubuntu bionic InRelease [242 kB]
Hit:2 https://repos-droplet.digitalocean.com/apt/droplet-agent main InRelease
Hit:3 http://mirrors.digitalocean.com/ubuntu bionic-updates InRelease
Hit:4 http://mirrors.digitalocean.com/ubuntu bionic-backports InRelease
Hit:5 http://security.ubuntu.com/ubuntu bionic-security InRelease
Get:6 http://deb.anydesk.com all InRelease [5588 B]
Hit:7 https://packages.clickhouse.com/deb stable InRelease
Get:8 http://deb.anydesk.com all/main amd64 Packages [644 B]
Fetched 248 kB in 1s (335 kB/s)
Reading package lists... Done
root@ubuntu-s-4vcpu-8gb-amd-sgp1-01:~# apt-get install anydesk
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libfile-desktopentry-perl libfile-mimeinfo-perl libgail-common libgail18 libgtk2.0-0 libgtk2.0-bin
  libgtk2.0-common libgtkglext1 libnet-dbus-perl libpangox-1.0-0 libtie-ixhash-perl libx11-protocol-perl
  libxml-twig-perl libxml-xpathengine-perl xdg-utils
Suggested packages:
  libunicode-map8-perl libunicode-string-perl xml-twig-tools
The following NEW packages will be installed:
  anydesk libfile-desktopentry-perl libfile-mimeinfo-perl libgail-common libgail18 libgtk2.0-0
  libgtk2.0-bin libgtk2.0-common libgtkglext1 libnet-dbus-perl libpangox-1.0-0 libtie-ixhash-perl
  libx11-protocol-perl libxml-twig-perl libxml-xpathengine-perl xdg-utils
0 upgraded, 16 newly installed, 0 to remove and 3 not upgraded.
Need to get 8989 kB of archives.
After this operation, 25.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Processing triggers for libc-bin (2.27-3ubuntu1.6) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for mime-support (3.60ubuntu1) ...
root@ubuntu-s-4vcpu-8gb-amd-sgp1-01:~
root@ubuntu-s-4vcpu-8gb-amd-sgp1-01:~# anydesk --get-status
online
root@ubuntu-s-4vcpu-8gb-amd-sgp1-01:~# echo "password" | anydesk --set-password
......

After running above commands, please follow this section to complete the Anydesk setting in the targeted machine.

@ezbik
Copy link

ezbik commented Sep 14, 2022

Awesome, so here is my fully automated script , tested on Ubuntu 20.04 with Anydesk 6.2.0.

https://gist.github.com/ezbik/4d43f66771aae9475ef7d36cc20a3aa0

@Tedpac
Copy link

Tedpac commented Mar 24, 2023

In Ubuntu I didn't need to put anything in ~/.anydesk/user.conf to do unattended logins, setting the password for AnyDesk using the root user was enough.

@JonahTzuChi
Copy link

When running the sudo echo [your-custom-password] | anydesk --set-password command, it should present the message:

Setting the password requires administrator privileges and an installed service. 1 / 1000

To resolve the above issue, it should change into the following command:

sudo echo openstack | sudo anydesk --set-password

unfortunately, I still get the same error Setting the password requires administrator privileges and an installed service. 1 / 1000

@JonahTzuChi
Copy link

In Ubuntu I didn't need to put anything in ~/.anydesk/user.conf to do unattended logins, setting the password for AnyDesk using the root user was enough.

Can you provide more information on this?

What I did was
su root
sudo echo [my-password] | sudo anydesk --set-password

But I still get back the same error, Setting the password requires administrator privileges and an installed service. 1 / 1000

@Tedpac
Copy link

Tedpac commented Apr 20, 2023

In Ubuntu I didn't need to put anything in ~/.anydesk/user.conf to do unattended logins, setting the password for AnyDesk using the root user was enough.

Can you provide more information on this?

What I did was su root sudo echo [my-password] | sudo anydesk --set-password

But I still get back the same error, Setting the password requires administrator privileges and an installed service. 1 / 1000

I just checked the history of commands I used and honestly I had no problem setting the password running this command (obviously using the root user): echo [password] | anydesk --set-password

I don't have much experience with AnyDesk (and ended up not using it because I couldn't solve the famous black screen problem after logging into Ubuntu), but maybe installing another version would solve your problem of setting the password.

@JonahTzuChi
Copy link

In Ubuntu I didn't need to put anything in ~/.anydesk/user.conf to do unattended logins, setting the password for AnyDesk using the root user was enough.

Can you provide more information on this?
What I did was su root sudo echo [my-password] | sudo anydesk --set-password
But I still get back the same error, Setting the password requires administrator privileges and an installed service. 1 / 1000

I just checked the history of commands I used and honestly I had no problem setting the password running this command (obviously using the root user): echo [password] | anydesk --set-password

I don't have much experience with AnyDesk (and ended up not using it because I couldn't solve the famous black screen problem after logging into Ubuntu), but maybe installing another version would solve your problem of setting the password.

Thank you for your reply, even you had decided to drop AnyDesk.
After some search around the net, I found a working solution.

  1. Switch to root

  2. update /etc/gdm3/custom.conf, which involve variables below:

    WaylandEnable=false
    AutomaticLoginEnable = true
    AutomaticLogin = $USERNAME
    

So far I managed to setup unattended access and it runs well. I don't experience black screen issue, I am on AnyDesk@6.2.1 and Ubuntu 22.04.2 LTS. Another thing to note, I still don't get a success in echo [password] | anydesk --set-password. But since it's up and I can set the password at GUI, I suppose my issue is solved now.

@Tedpac
Copy link

Tedpac commented Apr 23, 2023

@JonahTzuChi, thank you for your help, but my problem solving the black screen issue is that I'm trying to set up AnyDesk in Ubuntu 14.04 LTS, and this version of Ubuntu doesn't use gdm3, so I can't use those settings you provided. I can guarantee you that I tried everything I found online but to no avail. Either way, many people will find your settings useful.

@JonahTzuChi
Copy link

@JonahTzuChi, thank you for your help, but my problem solving the black screen issue is that I'm trying to set up AnyDesk in Ubuntu 14.04 LTS, and this version of Ubuntu doesn't use gdm3, so I can't use those settings you provided. I can guarantee you that I tried everything I found online but to no avail. Either way, many people will find your settings useful.

I believe you do! I feel like talking through a time tunnel 14.04LTS!!!

@rahulteja526
Copy link

sudo echo [my-password] | sudo anydesk --set-password

If you set a weak password, the command will not work. Suggested Password Eg: GitHub@2023

Reference: https://unix.stackexchange.com/questions/552742/how-to-enable-unattended-access-in-anydesk-debian-10-openbox-lightdm

This worked for me on Ubuntu 20

@fioranosoftwareadmin
Copy link

I am facing the issue with mint, can some give me the steps to clear this anydesk issue on mint

@fioranosoftwareadmin
Copy link

I have tried this in both ubuntu and mint, its not working still i see the same issue "please do not start anydesk as root user this might lead to unexpected behavior"

  1. we have a requirement where we need to login as root user and need to run the anydesk application
  2. In both ubuntu and Mint after logging as root in gui, the anydesk throws the same error
    Kindly provide some inputs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment