VNC server on Ubuntu with login screen after boot

Source:

The problem:

have a VNC server installed on Ubuntu and have it starting at boot with access to the login screen (Note: Vino, the default VNC server available on Ubuntu does not seem to allow access to the login screen after boot).

The solution:

1)

sudo apt-get install x11vnc
sudo x11vnc -storepasswd /etc/x11vnc.pass

2a)

for Ubuntu 15.04+ (systemd)

sudo nano /lib/systemd/system/x11vnc.service

and enter the following code

[Unit]
Description="x11vnc"
Requires=display-manager.service
After=display-manager.service

[Service]
ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /etc/x11vnc.pass
ExecStop=/usr/bin/killall x11vnc
Restart=on-failure
Restart-sec=2

[Install]
WantedBy=multi-user.target

then

sudo systemctl daemon-reload
sudo systemctl start x11vnc
sudo systemctl enable x11vnc

2b)

for Ubuntu 12.04-14.10 (upstart with lightdm)

sudo nano /etc/init/x11vnc.conf

and enter the following code

start on login-session-start
script
/usr/bin/x11vnc -xkb -auth /var/run/lightdm/root/:0 -noxrecord -noxfixes -noxdamage -rfbauth /etc/x11vnc.pass -forever -bg -rfbport 5900 -o /var/log/x11vnc.log
end script

then reboot.

if another display manager like GDM is used then the path here below must be changed accordingly. For example on Linux Mint 14.04 the file to edit is:

sudo nano /etc/mdm/Init/Default

and the line to add:

DISPLAY=:0 /usr/bin/syndaemon -d -i 1.0 -t -K -R
/usr/bin/x11vnc -xkb -auth /var/lib/mdm/:0.Xauth -noxrecord -noxfixes -noxdamage -rfbauth /etc/x11vnc.pass -forever -bg -rfbport 5900 -o /var/log/x11vnc.log
exit 0

Tunnel via SSH

The VNC port (5900) is not usually open for access from outside the local network, but if the machine has SSH access this can be used to tunnel the VNC connection. The easiest way is to use a VNC client that supports SSH tunneling (no further configurations needed on server or client). Remmina on Linux and TightVNC on Windows are good choices.

VNC server on Ubuntu with login screen after boot

Schedule Netgear ReadyNAS Ultra 2 backups with RSYNC over SSH

The problem:

The ReadyNAS Ultra 2 allows create scheduled backup jobs on remote RSYNC servers, using its web based control panel, but not over SSH, that could be very well the only option.

The solution:

Enable root SSH access to the ReadyNAS Ultra 2 unit and (using the command line) setup a CRON job.

Step1:

Enable root SSH on the ReadyNAS unit by installing the following extension: http://www.readynas.com/?p=4203

[Note: the “root” user password is the same as the one of the “admin” user]

Connect via SSH to the NAS

$ ssh root@IP_OF_NAS

Step2:

Generate public and private SSH keys (use no passphrase)

$ ssh-keygen

Step3:

Copy the public key on the remote server

$ ssh-copy-id -i ~/.ssh/id_rsa.pub remote_server_user@IP_OF_REMOTE_SERVER

Step4:

Edit crontab and add a scheduled RSYNC task

$ crontab -e

after issuing the above command it may very well show an error like

$ netgear-nas:~# crontab -e
 no crontab for root - using an empty one
 /bin/sh: /usr/bin/editor: No such file or directory
 crontab: "/usr/bin/editor" exited with status 127

this is because the default command line text editor is not correctly configured. Switching to “vi” is needed

$ EDITOR=/bin/vi; export EDITOR

now trying again

$ crontab -e

should work and crontab can be edited with vi

[Note: “vi” is hard for the less skilled user, but basic commands are easy enough to do simple edits to text files]

Step5:

Add a RSYNC task to crontab, save and exit

30 17 * * * rsync /nas/folder remote_server_user@IP_OF_REMOTE_SERVER:/path/where/place/backup/

Final note:

Better test the above RSYNC task directly from the command line and check if it will still ask for the password, it should not. If it still asks for the password the likely issue is because of wrong permissions of the

~/.ssh/authorized_keys

file on the remote host, ~/.ssh should be 700, and ~/.ssh/authorized_keys should be 600. If it still ask for the password check the permissions on ~ (should be 700 too).

See:

http://unix.stackexchange.com/questions/36540/why-am-i-still-getting-a-password-prompt-with-ssh-with-public-key-authentication

and/or

http://www.daveperrett.com/articles/2010/09/14/ssh-authentication-refused/

Schedule Netgear ReadyNAS Ultra 2 backups with RSYNC over SSH