Software & AppsOperating SystemLinux

How To View and Control a Remote Desktop through SSH

Ubuntu 18

In this article, we will delve into the process of viewing and controlling a remote desktop through Secure Shell (SSH). This can be particularly useful for system administrators who need to manage remote systems, or for anyone who needs to access their work computer from home.

Quick Answer

It is possible to view and control a remote desktop through SSH using various methods, such as using Vino VNC Server and Remmina or using x11vnc and SSH port forwarding. These methods allow you to securely access and manage remote systems or access your work computer from home.

What is SSH?

SSH, or Secure Shell, is a protocol that allows secure remote login from one computer to another. It provides strong password authentication and secure encrypted data communication between two computers connecting over an insecure network, such as the internet.

Prerequisites

Before we begin, ensure that you have SSH installed on both the local and remote machines. If not, use the following command to install OpenSSH:

sudo apt-get install openssh-server

Method 1: Using Vino VNC Server and Remmina

Step 1: Install Necessary Software

On the remote host machine, install the Vino VNC server and Remmina by running the following command:

sudo apt-get install vino remmina

Vino is a VNC server for GNOME that allows you to share your desktop with other users. Remmina is a remote desktop client that supports multiple network protocols, including VNC and SSH.

Step 2: Configure Vino Preferences

Next, connect to the remote host machine using SSH with trusted X11 forwarding enabled. This can be done using the following command:

ssh -Y user@remote

Here, -Y enables trusted X11 forwarding, user is your username on the remote machine, and remote is the IP address or hostname of the remote machine.

Once connected, open the Vino preferences on the remote host machine:

vino-preferences

In the Vino preferences, enable desktop sharing and configure the network to accept connections.

Step 3: Start the Vino Server

Start the Vino server on the remote host machine with the following commands:

sudo -s
export DISPLAY=:0.0
xhost +
/usr/lib/vino/vino-server &

Here, sudo -s opens a root shell, export DISPLAY=:0.0 sets the display environment variable, xhost + allows any host to connect to our X server, and /usr/lib/vino/vino-server & starts the Vino server.

Step 4: Configure Remmina and Connect

After logging out from the remote host machine and exiting the SSH session, open Remmina on your local machine and configure a new VNC connection. Enter the server address and enable SSH tunneling.

Save the connection and double-click on it to start browsing the remote desktop.

Method 2: Using x11vnc and SSH Port Forwarding

Step 1: Connect to the Remote Host

Connect to the remote host machine using SSH:

ssh user@remote

Step 2: Start x11vnc Server and Forward the VNC Port

Start the x11vnc server on the remote host machine and forward the VNC port over SSH:

ssh -L 5900:localhost:5900 user@remote "x11vnc -display :0 -noxdamage"

Here, -L 5900:localhost:5900 forwards the local port 5900 to the remote port 5900, and x11vnc -display :0 -noxdamage starts the x11vnc server on the remote machine.

Step 3: Connect Using a VNC Client

Use a VNC client on your local machine to connect to localhost:5900 and view/control the remote desktop.

Conclusion

In this article, we’ve explored two methods of viewing and controlling a remote desktop through SSH. These methods can be adapted based on your specific setup and requirements. Always remember to ensure the security of your connections, especially when dealing with remote systems.

What is SSH?

SSH stands for Secure Shell and is a protocol that allows secure remote login from one computer to another. It provides strong password authentication and secure encrypted data communication between two computers connecting over an insecure network, such as the internet.

What is the purpose of viewing and controlling a remote desktop through SSH?

Viewing and controlling a remote desktop through SSH is useful for system administrators who need to manage remote systems or for anyone who needs to access their work computer from home. It allows you to securely connect to and control a remote desktop as if you were physically present at the remote machine.

What are the prerequisites for viewing and controlling a remote desktop through SSH?

Before starting, you need to ensure that you have SSH installed on both the local and remote machines. If not, you can use the provided command (sudo apt-get install openssh-server) to install OpenSSH on Ubuntu-based systems.

What software do I need to install for Method 1?

For Method 1, you need to install the Vino VNC server and Remmina on the remote host machine. Vino is a VNC server for GNOME that allows desktop sharing, and Remmina is a remote desktop client that supports multiple network protocols, including VNC and SSH.

How do I configure Vino preferences?

To configure Vino preferences, connect to the remote host machine using SSH with trusted X11 forwarding enabled. Then, open the Vino preferences by running the command vino-preferences. In the preferences, enable desktop sharing and configure the network to accept connections.

How do I start the Vino server?

After configuring the Vino preferences, start the Vino server on the remote host machine by opening a root shell with the command sudo -s, setting the display environment variable with export DISPLAY=:0.0, allowing any host to connect to the X server with xhost +, and finally starting the Vino server with /usr/lib/vino/vino-server &.

What software do I need to install for Method 2?

For Method 2, you need to have x11vnc installed on the remote host machine. x11vnc is a VNC server that allows you to view and control the remote desktop.

How do I connect to the remote host using SSH for Method 2?

To connect to the remote host using SSH for Method 2, use the command ssh user@remote, where user is your username on the remote machine and remote is the IP address or hostname of the remote machine.

How do I start the x11vnc server and forward the VNC port?

After connecting to the remote host using SSH, start the x11vnc server and forward the VNC port by running the command ssh -L 5900:localhost:5900 user@remote "x11vnc -display :0 -noxdamage". This command forwards the local port 5900 to the remote port 5900 and starts the x11vnc server on the remote machine.

How do I connect to the remote desktop using a VNC client for Method 2?

To connect to the remote desktop using a VNC client for Method 2, use a VNC client on your local machine and connect to localhost:5900. This will allow you to view and control the remote desktop.

Leave a Comment

Your email address will not be published. Required fields are marked *