90 likes | 121 Views
Learn how to establish a secure VNC connection using the JSch package in Java. Create SSH tunnels for encryption and connect to VNC for remote desktop access.
E N D
Securing a VNC Connection with Java By Keith Lynn Field Trip #28
Packages • A package is a collection of related classes • The package we will use is called Jsch which can be downloaded from www.jcraft.org • This package allows us to make secure connections using the SSH protocol • We will use SSH and tunnels to provide a secure connection for VNC
JSch • The package Jsch contain classes necessary to create a secure connection • We create an instance of a Session which we create by using the username, host, and port • We then specify additional information • We set the property StrictHostKeyChecking to no so we don't get prompted with a question about storing the host when we connect • We also can specify which port should be tunneled
VNC • VNC stands for Virtual Network Computing • It will essentially allow us to make a remote desktop connection • However, there is no real encryption of passwords • So we use SSH to tunnel VNC and this will provide a level of encryption
JFrame • A JFrame is a top-level container • We can add other components to the JFrame • In this app, we will add labels, text fields, and a button • A JLabel allows us to put a label in the frame • A JTextField allows us to get input from the user • A JButton allows us to trigger an action
Events • In order to detect and act on the button click, we will create an event listener • The event listener we will create is an ActionListener • ActionListener is an interface which contains the method actionPerformed • If the listener is registered with the button, then when the button is clicked, actionPerformed is called • We can get a reference to the source of the event with the method getSource()
SSH • SSH is a secure communications protocol • It is a replacement for protocols like telnet which wasn't secure • In order to make the connection, we must have a server which accepts SSH connections and a client that can connect to the server
Executing External Programs in Java • When we click the button, we want to execute an external program which will start a vnc viewer • In order to execute the program, we will use a ProcessBuilder • This class allows us to execute a remote command • We must make sure that connect to the ProcessBuilder's input stream and read all of it
VncViewer • Vncviewer is a free utility that will allow us to connect to a VNC server • We specify the port that'd we've tunneled through SSH and use 127.0.0.1 as the hostname • If everything is connected correctly, you should see the desktop