Skip to content
Snippets Groups Projects
Commit 6baab017 authored by Michael Blaschek's avatar Michael Blaschek :bicyclist:
Browse files

Update Python/README.md, SSH-VPN-VNC/README.md, SSH-VPN-VNC/add_xrandr_resolution.sh files

parent 605d47bf
Branches
Tags
No related merge requests found
......@@ -27,3 +27,20 @@ The idea is to install a conda or virtual environment and use that as a kernel f
[Teaching-Hub Spawn](QA-004-TeachingHub-SpawnFailed.md)
This usually happens because of an old configuration. Try to remove `~/.jupyter` on SRVX1.
## Q: Executing Python code on remote servers?
[Remote IPython Kernels](QA-005-Remote-Kernels.ipynb)
The idea is to launch an interactive IPython console on your computer (Linux or Mac, not sure about Windows) with a kernel on the server.
## Q: What Python IDE to use with remote kernels?
There are a lot of different ways to develop in python.
Some are:
- [Visual Studio Code](https://code.visualstudio.com/)
- [PyCharm](https://www.jetbrains.com/de-de/pycharm/)
- Editors like Emacs, Sublime, Vim,...
- Jupyter Notebooks and Lab e.g. on `Jupyterhub@srvx1` or `jupyterhub@jet`
and `atom`. This is simple editor available on any platform and it can be extended with packages to become a full grown IDE with the power of open source.
[Atom-IDE-Install](QA-006-Atom-IDE.md)
......@@ -2,7 +2,146 @@
[[_TOC_]]
## Q: How to transfer files between two VPN networks?
## General Access
Please use these methods to access the servers:
1. SSH
2. JupyterHub
3. VNC
## SSH
**From any computer in the IMGW subnet**: Log in via ssh by typing either of the following in a terminal (there are two redundant login nodes, jet01 and jet02). Replace `[USERNAME]` with your own.
```bash
ssh -X [USERNAME]@srvx1.img.univie.ac.at
ssh -X [USERNAME]@srvx8.img.univie.ac.at
ssh -X [USERNAME]@jet01.img.univie.ac.at
ssh -X [USERNAME]@131.130.157.215
ssh -X [USERNAME]@jet02.img.univie.ac.at
ssh -X [USERNAME]@131.130.157.216
```
The `-X` option enables X11 forwarding via ssh, i.e., permits opening graphical windows.
**From eduroam**: You should be able to log in as above.
**From the outer world**: First connect to the [UniVie VPN](https://zid.univie.ac.at/en/vpn/), then start up a terminal and log in as above.
If you are a guest, you can apply for a [guest u:account](https://zid.univie.ac.at/uaccount/#c11096). This will give you access to eduroam and to the VPN. Your application needs to be endorsed by a staff member, who also determines the expiration date of the account.
## VNC
**Be aware! Everyone with the VNC password will get access to your account**
It is recommended not to use VNC. Use **jupyterhub** or **screen** instead.
The VNC (Virtual Network Computing) allows to view a graphical user interface (GUI) from a remote server in an viewer application. This can be used to launch GUI programs on the servers.
Xvnc is the Unix VNC server. Applications can display themselves on Xvnc as if it were a normal display, but they will appear on any connected VNC viewers rather than on a physical screen. The VNC protocol uses the TCP/IP ports 5900+N, where N is the display number.
### Connecting, setting the window manager
Use a VNC client (e.g. the [RealVNC VNC Viewer](https://www.realvnc.com/en/connect/download/viewer/windows/) on Windows, or [Remmina](https://remmina.org/) on any Linux distribution) and connect to `131.130.157.215:[DISPLAY]`.
The VNC server will automatically start a graphical window manager/desktop environment. Details are stored in `.vnc/xstartup`. Your default configuration will load GNOME, and `.vnc/xstartup` will be something like this:
```bash
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
/etc/X11/xinit/xinitrc
# Assume either Gnome will be started by default when installed
# We want to kill the session automatically in this case when user logs out. In case you modify
# /etc/X11/xinit/Xclients or ~/.Xclients yourself to achieve a different result, then you should
# be responsible to modify below code to avoid that your session will be automatically killed
if [ -e /usr/bin/gnome-session ]; then
vncserver -kill $DISPLAY
fi
```
It is recommended to use IceWM instead. This is a more lightweight alternative to GNOME. To switch to IceWM, first log out from GNOME and disconnect from your VNC viewer, then change your `.vnc/xstartup` to this:
```bash
#!/bin/sh
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry -sb -sl 500 -fn 9x15bold -title "$VNCDESKTOP Desktop" &
icewm &
```
Finally stop/restart the VNC server.
```bash
systemctl --user restart vncserver@:[DISPLAY].service --now
```
Monitor the status:
```bash
systemctl --user status vncserver@:[DISPLAY].service
vncserver@:7.service - Remote desktop service (VNC)
Loaded: loaded (/jetfs/home/mblaschek/.config/systemd/user/vncserver@.service; enabled; vendor preset: e>
Active: active (running) since Mon 2020-10-05 17:00:23 CEST; 3 months 8 days ago
CGroup: /user.slice/user-54212.slice/user@54212.service/vncserver.slice/vncserver@:7.service
├─ 32405 gpg-agent --homedir /root/.emacs.d/elpa/gnupg --use-standard-socket --daemon
├─ 59959 /usr/bin/gnome-keyring-daemon --start --foreground --components=secrets
├─ 116498 /usr/lib64/firefox/firefox -contentproc -childID 47 -isForBrowser -prefsLen 10637 -pre>
├─ 177114 /bin/sh /usr/bin/xdg-open about:blank
├─ 177225 /usr/lib64/firefox/firefox about:blank
...
```
### Change the resolution of your VNC Session
`xrandr` gives you a list of available resolutions, that can be used.
Change the resolution to e.g. 1920x1080 (HD):
```
xrandr -s 1920x1080 -d $DISPLAY
```
Adding resolutions according to your display's resolution have a look here: [add_xrandr_resolution.sh](add_xrandr_resolution.sh)
## Screen
[Screen](https://wiki.ubuntuusers.de/Screen/) is terminal session manager, that allows to start processes and reconnect to these processes after disconnection.
This starts a new session
```bash
screen -S longjob
```
You can detach from this session with `CTRL + A + D` and reconnect again with `screen -r`.
Multiple Sessions can be created and the output saved.
## Jupyterhub
On SRVX1 the TeachingHub and on Jet01 the ResearchHub is running and available to users and students. Connect to either [https://srvx1.img.univie.ac.at](https://srvx1.img.univie.ac.at) from everywhere or [https://jet01.img.univie.ac.at](https://jet01.img.univie.ac.at) from within the university network.
# Q: ssh using key authentication?
In order to connect passwordless to a remote server a key needs to be generated.
```bash
>>> ssh-keygen -b 4096
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in .ssh/id_rsa
Your public key has been saved in .ssh/id_rsa.pub
The key fingerprint is:
SHA256:lHEKWnP+1vdNfbSELXApKpFvllcgCp3DHsgrbO2RYuo mblaschek@pop-os
The key's randomart image is:
+---[RSA 4096]----+
| ..B =..o... |
| =.&.=..ooo |
| . o +.X o oo o.|
| * = + B o o.o|
| + + . S + . ..+|
| . . . . oo|
|. o|
| E |
| |
+----[SHA256]-----+
```
It is recommended to use a password to encrpyt the private key `.ssh/id_rsa`. However, this password is then required to login.
Todo add infos on `ssh-agent`
# Q: How to transfer files between two VPN networks?
You should be able to use an SSH tunnel.
......@@ -23,7 +162,7 @@ I just tested this on my network, and it worked perfectly.
The above method is fine if the remote network is secure, but if it is not secure,
you'd need to establish a tunnel between local and gateway, and another tunnel between gateway and remote, linking the two by a common port number.
## Q: How to connect to Jet, SRVX8, SRVX2?
# Q: How to connect to Jet, SRVX8, SRVX2?
Currently (01.2021) only `srvx1.img.univie.ac.at` and `login.univie.ac.at` are available from the internet.
Please replace `[USER]` with your username on these servers and adjust the servers to your needs.
......
#!/bin/bash
#
# Add custom VNC resolution
# Author: M Blaschek
# Date: 08-2020
# Requires: xrandr and a running VNC session
if [ $# -ne 2 ]; then
echo "e.g. try: $0 1920 1380"
echo "or 2560 1320"
else
command=$(cvt $1 $2 60 | grep Modeline | awk '{for(i=3;i<NF;i++){printf "%s ",$i}}')
xrandr --newmode "$1x$2" ${command/Modeline/}
xrandr --addmode VNC-0 "$1x$2"
xrandr -d $DISPLAY -s "$1x$2"
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment