Skip to content

Instantly share code, notes, and snippets.

@SomajitDey
Last active March 25, 2024 15:43
Show Gist options
  • Save SomajitDey/2fd80c9d64762cf5ba7e09f676f7a360 to your computer and use it in GitHub Desktop.
Save SomajitDey/2fd80c9d64762cf5ba7e09f676f7a360 to your computer and use it in GitHub Desktop.

How to use Anydesk to connect to remote network with low bandwidth usage

Anydesk is usually used for accessing remote desktop, viz. the entire GUI shell. This, however, uses a lot of data. If one wants to simply run commands remotely, then it's more efficient to use SSH by using Anydesk's TCP tunneling feature. TCP tunnelling also gives access to remote's network provided a SQUID web proxy is running @ remote, thus setting up a VPN effectively. Anydesk offers only one TCP tunneling in its FREE license.

To set up SSH, for example, to a Remote Linux server do the following:

  1. Setup Anydesk server in remote. Make sure Create TCP tunnels is checked in Settings > Permissions.
  2. Open Anydesk client in your Windows computer.
  3. Sign in to your Anydesk Account, otherwise TCP tunneling would be greyed out.
  4. Connect to Remote in the Anydesk app and set up TCP tunneling. Say, we forward local port 22221 to remote port 22.
  5. Open cmd.exe and SSH to Remote: ssh <remote_user>@localhost -p 22221.
  6. To save data, when connecting to Remote in the Anydesk app, use the Browse Files mode, not the full Connect mode.

To SSH to Remote from WSL2:

  1. Forward another Windows port, say, 22222 to localhost:22221 using the Powershell command: netsh interface portproxy add v4tov4 listenport=22222 listenaddress=0.0.0.0 connectport=22221 connectaddress=localhost. Effectively now, Anydesk listens to localhost:22222 and accepts connections from all IPs, by virtue of listenaddress=0.0.0.0. Step 4 above may not in itself ensure such aceeptance of incoming connections from all IPs.
  2. SSH to Windows:22222 from WSL2 by following the steps mentioned here.
  3. Setup an ssh-host-alias for convenience.

Setting up SSH from WSL2 is important in case one wants to use nautilus in WSL2 to work with (i.e. move, copy, rename, edit, view etc.) files in Remote. Nautilus looks and feels better than the native Browse Files utility in Anydesk. To set up nautilus like that do:

  1. Install nautilus in WSL2: sudo apt install nautilus -y
  2. Install gvfs-backends: sudo apt install gvfs-backends
  3. Install gvfs-fuse: sudo apt install gvfs-fuse
  4. Install gvfs-smb: sudo apt install gvfs-smb
  5. wsl --shutdown in Powershell or cmd.exe.
  6. Relaunch WSL2 > nautilus or simply Files(Ubuntu) from the Windows Start menu.
  7. Ctrl+L or Other Locations > Connect to Server to sftp://<remote-user>@<Win_IP>:22222

Another option is to use WinSCP connecting to sftp://<remote-user>@localhost:22221

N.B: If the newest version (in Windows) doesn't support TCP tunnelling, fall back to earlier versions. I tested with v6.2 on both Windows and Linux.

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