screen---+!! My Sandbox
VNC on lxplus
VNC is very useful for working on lxplus (or any remove computer) for at least two reason:
- It is much faster than X forwarding if you open any GUIs or additional windows.
- If you loose you connection, it will not affect what you are working on. Everything will be waiting for you when you reconnect.
The basic idea is that you start a desktop/window manager
on the remote computer and then you connect to it with your local computer. Everything is running on the remote machine and it is just sending you the image of the screen and taking your keyboard and mouse a input. So it is just as if you connected your monitor, keyboard, and mouse directly to the remove computer. Of course, if your connection is slow, it might lag a little, but it will always be faster than X forwarding and if you loose your connection it doesn't have any impact on what your were running.
Part 1: Starting a VNC server on an lxplus node
- Log in to an lxplus node, but keep track of which one you are actually sent to (e.g. lxplus701.cern.ch), you will need to connect this specific lxplus machine to use VNC.
ssh ${USER}@lxplus.cern.ch
- Set up a
screen
session and set up kerberos and afs tickets so that the VNC server you start will keep running after you disconnect. (For more information on screen
, see the manual pages or google.)
screen
kinit
(enter your password)
- Start the VNC server with the geometry you want and the display number you want (e.g., :2). If display :2 is already in use, you will have to pick another number. It doesn't matter which display number you choose, but you must remember which one you used in order to connect later on. (I find the geometry 1880x970 convenient for 1920x1080 screens because you can see the whole desktop without going to fullscreen mode.).
vncserver -geometry 1880x970 :2
- If this is the first time you have started a VNC server:
- You will need to choose a password. It can be whatever you want, it doesn't have to be the same as your CERN nice password, but it should not be too weak.
- By default, the VNC server may start a really basic window manager (twm). You want it to start a more useful window manager like KDE (you could also start gnome, but I use KDE), so do the following:
- Stop the VNC sever you just started:
vncserver -kill :2
- Open the file
~/.vnc/xstartup
and comment out the line with twm &
and add the line startkde &
, so it looks like:
#twm &
startkde &
- Now start the VNC server again:
vncserver -geometry 1880x970 :2
- Now detach the
screen
session with: CTRL+a CTRL+d. This will keep the screen
session running in the background so the VNC server will not die when you log out of lupus. If you did this right, you will go back to the terminal you were in before you started screen
and it will say [detached]
.
- Make sure you remember the node you are on and the VNC display number you are using and log out of lxplus.
- You can now close this terminal.
Part 2: Connecting to a VNC server that is running on lxplus
- Make an ssh tunnel from the VNC port on your local computer to the VNC server you started on lxplus. The lxplus node is the one from Part 1 and the port number is 590X, where X is the display number from Part 1. If you started the VNC server on lxplus0045 with display number :2, then you make the tunnel with:
ssh -Y -L 5902:localhost:5902 ${USER}@lxplus601.cern.ch
- You will probably need to re-up your credentials in the screen session running the server (you probably have to redo kini every time you connect the ssh tunnel to keep the screen session running the vncserver from losing permissions):
screen -r
kinit
(enter your password)
- Detach the
screen
session with: CTRL+a CTRL+d
- Now start a VNC client on your local computer and connect to localhost:5902. If you don't have a VNC client, you will need to install one. TightVNC and Vinagre are popular options.
- You will need to enter your VNC password and then a window should come up with the VNC desktop that is running on lxplus. Enjoy! (Or see below for troubleshooting.)
Troubleshooting
- If you are not able to connect, it could be that the afs permissions have expired in the
screen
session where the VNC server is running, so it cannot read and write to you directory. You should be able to fix this with the following:
- Log in to the lxplus node that is running your VNC server. For example, if you started it on lxplus601, then:
ssh ${USER}@lxplus601.cern.ch
- Connect to the
screen
session in which you are running the VNC server:
screen -r
- You should now be back in the
screen
session where you started the VNC server. If you do an ls
you will see that your afs permissions are now gone. To get them back:
kinit
(enter your password)
- Now everything should work again
- Detach the
screen
session with: CTRL+a CTRL+d
- You can now exit out of this window.
- It could also be that the VNC server was killed and no longer exists. Although VNC servers should be able to run forever, it seems that sometimes they get killed on lxplus, maybe for maintenance purposes. If you go to the node that should be running your VNC server and it's not running, you will just need to start a new one.
- It could be that the VNC server is still running, but the
screen
session it was started in is not. I'm not sure how this happens, but it does and I don't know how to fix it. The only thing I know to do is kill the VNC server and start a new one in a new screen
session. (If anyone knows a better way, please let me know.)
Focus follows mouse
- For some reason, the ability to set things like focus-follows-mouse and other window behavior was removed from the system preference GUIs in newer version of linux. However, these feature can still be set from the command line using gconftool-2.
- To set focus-follows-mouse:
gconftool-2 -s /apps/metacity/general/focus_mode -t string mouse
- To set sloppy focus-follows-mouse:
gconftool-2 -s /apps/metacity/general/focus_mode -t string sloppy
- To get the correct focus setting:
gconftool-2 -g /apps/metacity/general/focus_mode
- To list all of the general settings:
gconftool-2 -a /apps/metacity/general
Links