2017-10-07 11:43:26 +09:00
|
|
|
---
|
|
|
|
title: Forward X11 window over SSH
|
|
|
|
date: 2017-06-16 00:00:00 +09:00
|
|
|
|
---
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
## Ubuntu 16.04
|
|
|
|
|
|
|
|
Make sure you have installed SSH, X11 and xAuth on a remote server.
|
|
|
|
|
|
|
|
```
|
|
|
|
sudo apt install -y xorg xauth openssh
|
|
|
|
sudo sed -i '/ForwardX11/s/.*/ForwardX11 yes/' /etc/ssh/sshd_config
|
|
|
|
sudo service ssh restart
|
|
|
|
```
|
|
|
|
|
|
|
|
## macOS Sierra
|
|
|
|
|
|
|
|
You also need to have X11 on your local machine.
|
|
|
|
|
|
|
|
```
|
|
|
|
brew cask install xquartz # install X11
|
|
|
|
ssh -X <remote>
|
|
|
|
$ xeyes # verify you have X11
|
|
|
|
```
|
|
|
|
|
|
|
|
You might want to restart macOS if `$DISPLAY` have empty value.
|
|
|
|
|
|
|
|
# Plot with matplotlib
|
|
|
|
|
|
|
|
Plot a simple graph remotely on Ubuntu 16.04:
|
|
|
|
|
|
|
|
```python
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
plt.plot([1, 2, 3])
|
|
|
|
plt.show()
|
|
|
|
```
|
|
|
|
|
2018-08-03 14:06:51 +09:00
|
|
|
If you can't see any window, add **backend** settings to `~/.config/matplotlib/matplotlibrc`.
|
2017-10-07 11:43:26 +09:00
|
|
|
|
|
|
|
```ini
|
|
|
|
backend: TkAgg
|
|
|
|
```
|
|
|
|
|
|
|
|
or just add few lines to change the backend explicitly:
|
|
|
|
|
|
|
|
```python
|
|
|
|
import matplotlib
|
|
|
|
matplotlib.use('TkAgg')
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
...
|
|
|
|
```
|