====== Remote Access with VNC ======
[[https://en.wikipedia.org/wiki/Virtual_Network_Computing|Virtual Network Computing (VNC)]] is a graphical desktop-sharing system that uses the Remote Frame Buffer protocol (RFB) to remotely control another computer. It transmits the keyboard and mouse events from one computer to another, relaying the graphical-screen updates back in the other direction, over a network.
With some minor setup, you can use VNC to access your EECS account from your home machine with access to all the software installed on EECS systems and your home directory.
The setup instructions below assume that you are [[login:sshsupport|connected to an EECS tech-supported Linux system]] via SSH. For undergrad users, this means you are connected to "red.eecs.yorku.ca" via SSH. For other users, this means you are connected to "indigo.eecs.yorku.ca".
====== VNC Password Setup =====
The first time you use VNC, you need to setup a password. You will need to enter this password on your PC when you want to access your EECS VNC session remotely.
Use the //vncpasswd// command to set a VNC password:
% vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
As you can see, //vncpasswd// will ask for a password, then ask you to re-type it to verify it. It also gives you the option of setting a "view only" password which you don't need. The encrypted password will be written to the file ~/.vnc/passwd in your home directory.
You can re-run the //vncpasswd// command any time you wish to change your VNC password.
**Since VNC is an older protocol, it limits maximum password length to 8 characters. Please ensure that you use a secure password, or someone may be able to gain unauthorized access to your account contents.**
====== Check If a VNC Server Is Already Running ======
You will be connecting from your own computer to an application on our server called a "VNC Server". There will be one VNC Server application running on our server per user that is connecting.
First, check to make sure that you aren't running an existing VNC server using the //vncserver// command with the list option. If this is the first time you've used VNC, you can skip this step!
Here we can see that an existing VNC server is not running:
% vncserver -list
TigerVNC server sessions:
X DISPLAY # PROCESS ID
If a VNC server was already running, the output would look like this:
% vncserver -list
TigerVNC server sessions:
X DISPLAY # PROCESS ID
:2 18734
If you want to start a VNC server for your user ID on our server, continue to the next step.
If you've already started a VNC server for your user ID on our server, skip to the section
[[https://wiki.eecs.yorku.ca/dept/tdb/login:vnc:start#connecting_to_your_vnc_server]].
====== Starting a VNC Server ======
In order to start the VNC server, run the //vncserver// command:
red% vncserver
New 'red:2 (bob)' desktop is red:2
Starting applications specified in /eecs/home/bob/.vnc/xstartup
Log file is /cs/home/bob/.vnc/red:2.log
Here we can see that the VNC server has started on "red:2". The "red" part is because the server is running on "red.eecs.yorku.ca". The ":2" part is the VNC server port. You will need both the hostname and port number when connecting to the VNC server from your computer in the next step.
IMPORTANT NOTE: By default, the VNC sessions start with screen resolution of 1024x768. If you want a larger screen resolution (eg. 1920x1080), then you need to pass this to the vncserver command like this: //vncserver// -geometry 1920x1080. Note that the larger the screen resolution, the slower the session will be because more data needs to be sent back and forth over your network connection.
====== Connecting to Your VNC Server ======
Now that you've started a VNC server process on the time sharing server, it's time to connect to it from your local computer. See the section "VNC Clients" for recommendations on VNC clients for a variety of platforms.
For the purposes of this example, I will assume Mobaxterm running on a Windows system. Follow the following procedure to connect to your VNC session:
* Select "Sessions"
* Select "New session"
* Select "VNC"
* Under "Remote hostname or IP address" enter "red.eecs.yorku.ca" if you an undergrad, or "indigo.eecs.yorku.ca" if you are anyone else.
* Beside "Remote hostname or IP address", you will see "Port". If the port you were given above (red:2) is 2, then enter "5902". If the port you're given was "10, then select "5910". The port will always be 59XX where XX is a 2 digit port.
* Click "OK".
* You should see a dialog box that says: "Please enter your password for vncuser on red.eecs.yorku.ca". Enter the password that you entered from //vncpasswd// above. Click "OK".
* You should now be connected to your VNC session.
====== Stopping VNC Server ======
If you don't take steps to stop a running VNC server, it will continue to run when you logout. This might seem useful to you because all your applications will continue to run. This does, however, pose two major problems:
1) The time sharing servers have limited resources available. If everyone were to run a VNC server and keep it running with all the software they are running all the time, our server will run out of memory, and CPU power. It will operate slowly for everyone, and provide a poor user experience.
2) If you leave a VNC session running, you provide a mechanism for outside users to access your account.
**PLEASE** make sure that you explicitly stop any running VNC server when your session is done. Stopping the VNC server is actually very easy. There are two ways to do it:
* You can stop the VNC server by simply logging out! Either double click the "Logout" icon on the desktop, and choose "Log Out", or click the small arrow in the upper right hand corner of the screen, select your name, then "Log Out".
* You can use the //vncserver// command with the list option to see the port number of your VNC instance, then use //vncserver// -kill (eg. vncserver -kill :2). Your VNC server will be stopped.
** Users who consistently abuse the system by leaving VNC sessions open that they are not actively using may have their account locked without notice. **
====== VNC Clients ======
VNC clients are available for a variety of platforms.
* Windows: For Windows, we recommend [[https://mobaxterm.mobatek.net/|MobaXterm]]. RealVNC's VNC Viewer is another option.
* MacOS X: MacOS X has built-in support for VNC. Go to the Finder, hit CMD-K, then in the "Server Address" field enter "vnc:%%//%%HOST:port". For example: vnc:%%//%%red.eecs.yorku.ca:5902
* Linux: Most Linux systems have RealVNC's "vncviewer" installed, or it can be easily installed with the OS package management solution.