Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,17 @@ collections:
status: draft # draft or published
published: 2019-11-13
author: Ming Fu <[email protected]>

x11forwarding:
output: true
permalink: /:collection/:name
title: X11 Forwarding
summary: "Learn to use X11 Forwarding to run graphical applications on virtual machine."
category: Intermediate
tags:
- tutorial
difficulty: 2 # number from 1 to 5
duration: 15 # number of minutes
status: draft # draft or published
published: 2019-11-28
author: Ming Fu <[email protected]>
24 changes: 24 additions & 0 deletions _x11forwarding/01-overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: Overview
order: 1
duration: 5
---

Users can connect to Nectar virtual machine using a variety of SSH (Secure Shell) clients and most of these terminals are text based. If you need to use some GUI applications on your virtual machine, you need to use SSH clients with X11 forwarding enabled.

The X11 forwarding is a software package and network protocol that lets you interact locally, using your personal computer's display, mouse, and keyboard, with the graphical user interface of an application running on a virtual machine. X11 forwarding allows user to start up applications on remote virtual machine but forward the graphical display to your local machine. The connection between your laptop and virtual machine is secured via SSH connection.

**Cloud One**
This tutorial is part of the Nectar Cloud One curriculum. You should be familiar with the basics of virtual machine and know how to launch and access a virtual machine in Nectar Cloud. If you think you need help with any of that, you should complete [Cloud Start tutorial](/cloud-starter/01-overview) before you start here.
{: .callout-warning}

### What you'll learn

- Configure virtual machine to enable X11 forwarding
- Install X server
- Access graphical application via SSH

### What you'll need

- A running virtual machine with Ubuntu 19.04 installed
- Terminal Software
70 changes: 70 additions & 0 deletions _x11forwarding/02-enable-x11-on-virtual-machine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
title: Enable X11 Forwarding on Virtual Machine
order: 2
duration: 5
---

There are a few changes needed on the virtual machine to enable X11 forwarding. In this tutorial we use Ubuntu 19.04. Other Linux distributions will have a very similar SSH daemon configuration. The SSH daemon configuration file is located at `/etc/ssh/sshd_config`.

1) Open the SSH daemon configuration file.

```bash
$ sudo vi /etc/ssh/sshd_config
```
2) Locate and uncomment or change line `X11Forwarding` to be `X11Forwarding yes`. This line allows the graphical application to be forwarded over to your computer.

```bash
# GSSAPI options
GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path

```

3) Restart SSH daemon.

```bash
$ service sshd restart

```
4) Install a graphical application `xeyes` for testing.

```bash
$ apt -y install xeyes

```
30 changes: 30 additions & 0 deletions _x11forwarding/03-install-x-server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: Install X server
order: 3
duration: 5
---

For X11 forwarding in SSH to work on your computer, X server must be installed and running. The X server is a software package that manages the connection between the remote graphical application and your computer. It receives the input from your computer and renders the graphical interface.

Most Linux has X server installed, so you really don't need to do anything. However, if your computer is running Windows or macOS, you will need to install and run an X server application.

### Installation of X server on Windows

In Windows, you can download and install `Xming` X server. For X11 forwarding to work, you will need to start `Xming` before connecting to the virtual machine with your SSH Client.

1) Download the [Xming](https://sourceforge.net/projects/xming/) to a folder and double click the installer to start the installaltion process.

![Xming Download Page]({{ site.baseurl }}/assets/images/x11forwarding/x11-1.png)

2) Following the steps in the `Xming` Setup Wizard to finish the installation.

![Xming Setup Wizard Page]({{ site.baseurl }}/assets/images/x11forwarding/x11-2.png)

3) In the `Windows Security Alert` window, click `Allow access` button to config firewall to allow `Xming` network connection.

![Xming Firewall Alert Page]({{ site.baseurl }}/assets/images/x11forwarding/x11-3.png)

### Installation of X server on Mac

For Mac OS, download and install `XQuartz` X server. For X11 forwarding to work, you will need to start `XQuartz` first before making an SSH connection to the virtual machine. Download the [XQuartz](https://www.xquartz.org/) and install it in your Mac OS.

59 changes: 59 additions & 0 deletions _x11forwarding/04-config-ssh-client-with-x11.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
title: Use X11 Forwarding in SSH Client
order: 4
duration: 5
---

After the X server is installed in your operating system, you can connect to virtual machine with X11 forwarding enabled in your SSH Client

### Linux SSH Client

In Linux, SSH terminal supports X11 forwarding by default, so you don't need to install anything. You can connect to your virtual machine by typing:

```bash
$ ssh -i <your private key> -X username@ip address

```
After you connected to your virtual machine, you can type the below command to test whether X11 forwarding is working:

```bash
$ xclock

```

### Mac OS SSH Client

In Mac OS, you may need to edit the `sshd_config` file (by default, the file path is in `/etc/ssh/sshd_config` or `/etc/sshd_config`) to enable X11 forwarding. If your `sshd_config` file includes `#X11Forwarding no` or just `X11Forwarding no`, uncomment out the line by removing the leading `#` or change it to `X11Forwarding Yes`. If your `sshd_config` doesn't include the line, you can add the line `X11Forwarding Yes` to the file.

Once X11 forwarding is setup, you can type the same common as Linux:

```bash
ssh -i <your private key> -X username@ip address

```

After you connected to your virtual machine, you can type the below command to test whether X11 forwarding is working:

```bash
$ xclock

```

## Windows SSH Client

In Windows, you can use putty to connect to your virtual machine with X11 forwarding enabled.

1. Open Putty and fill in the `username` and `IP address` of your virtual machine.

![Putty Page 1]({{ site.baseurl }}/assets/images/x11forwarding/x11-4.png)

2. Go to the `Connection` menu and click the `+` in front of `SSH` to exapnd the list. Select `X11` in the drop-down list. Tick the box `X11 forwarding`. Type `localhost:0` in `X display location`. Then click the `open` button.

![Putty Page 2]({{ site.baseurl }}/assets/images/x11forwarding/x11-5.png)

After you connected to your virtual machine, you can type the below command to test whether X11 forwarding is working:

```bash
$ xclock

```
11 changes: 11 additions & 0 deletions _x11forwarding/05-x11-next-steps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Next Steps
order: 5
duration: 2
---

In this tutorial you learnt how to install X server and enable X11 forwarding in your SSH client. Now, you can connect to your virtual machine and run graphical applications remotely using X11 forwarding.

**Cloud One**
Congratulations. You've completed another step on your Cloud Computing journey. Continue with the Cloud One Series.
{: .callout-success}
3 changes: 3 additions & 0 deletions _x11forwarding/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
redirect_to: /x11forwarding/01-overview
---
Binary file added assets/images/x11forwarding/x11-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/x11forwarding/x11-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/x11forwarding/x11-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/x11forwarding/x11-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/x11forwarding/x11-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.