Vnc Port For Mac

  



How to Allow VNC Ports. To access VNC on a public network (e.g. The Internet), you must forward the appropriate ports through your router/firewall. The exact steps are based on your specific router model. Here’s a basic guide to port-forward VNC Ports: Find the local IP Address of your PC running VNC Server. Feb 26, 2013 You should now have a VNC server running on the standard port 5900 of your machine. You should (in theory) be able to connect to your Mac with any viewer using your machine’s IP address and the port. As I mentioned before, I had some issues connecting from Windows, and had to take a few precautions.

This guide illustrates the concepts for tunneling VNC over SSH. VNC is a protocol that allows you to control a desktop from a remote computer and allows others to view or control your desktop from their computer. However, using VNC alone can be a security risk. Although VNC uses password encryption, the rest of the traffic is sent unencrypted.

Mac

SSH or Secure Shell, is a secure protocol with a feature called port forwarding that can be used to provide secure connections for VNC, as well as for POP3, SMTP, RDP, HTTP and other protocols. Using SSH port forwarding to secure connections is also known as SSH Tunneling. SSH tunneling creates a SSH tunnel to encapsulate unencrypted traffic (the payload protocol), such as VNC, over an encrypted SSH channel (the delivery protocol). In other words, using VNC with SSH port forwarding makes a port from one PC appear on another PC through a SSH connection, providing a secure path for the VNC traffic.

A practical use of SSH tunneling with local and remote port forwarding would be to securely exchange the desktops between two PCs using the VNC protocol. Setting up the SSH sessions can be accomplished for both PCs from the same SSH client PC. Another use for SSH tunneling not covered in this guide is to bypass firewalls that block certain ports, such as port 80, which are often blocked to prevent users from accessing the Internet using company computers (see related article – Using SSH to secure Internet connections).

SSH Port Forwarding Summary

In the following definitions and examples, a remote machine is defined as the PC with the SSH server. All commands in the examples here are executed from the SSH client machine (192.168.1.1). Although both forwarded and local ports may be the same, the examples shown use different port numbers for clarification.

Two types of SSH port forwarding are: (1) local port forwarding, and (2) remote port forwarding, with local port forwarding being the more common. Another type of SSH port forwarding not covered in this guide, is Dynamic port forwarding (see Using SSH to secure Internet connections).

1. Local port forwarding – A port from the client PC is forwarded to the remote PC. A connection to this port enables data to be sent bidirectionally over the SSH connection between the client and remote PC. See Fig 1.

2. Remote port forwarding – This is a reverse of local port forwarding. A port from the remote PC is forwarded to the client PC. A connection to this port enables data to be sent bidirectionally over the SSH connection between the client and remote PC. See Fig 2.

Other points:

Vnc Port For Mac 10.10

  • Ports may be forwarded to multiple hosts on a single connection or by using multiple SSH connections.
  • Other computers on the Internet are prevented from connecting to forwarded ports unless enabled with the “-g” flag.
  • VNC servers must allow loopback connections since clients are seen as local connections.
  • To connect PCs over the Internet, port 22 must be forwarded for SSH on the router.
  • Port numbers from 0 to 1023 are privileged ports used by system processes to provide network services. For Unix and Unix-like operating systems, these processes can only execute with superuser privileges. It’s therefore best to avoid using ports under 1024 for local ports.

Local Port Forwarding for VNC

Figure 1 illustrates local port forwarding for a VNC session (click to enlarge) over a LAN. The client Windows PC has IP address 192.168.1.1 and the remote Linux PC has IP address 192.168.1.3. The syntax for local port forwarding as used in this example:

Note: The use of a Windows PC and Linux machine in the Figure 1 below is for illustration purposes only. The operating systems are irrelevant. What matters is that client PC has a SSH client and VNC viewer, and the remote machine has a SSH server and VNC server.

Fig 1

Vnc

To establish the SSH connection using local port forwarding, the following command can be entered into a command window on the client PC:

  • [email protected] = SSH host to connect to
  • -L = Option to enable local port forwarding
  • 6999 = Port on the client PC
  • localhost = Host server to connect to (the remote PC, same as 127.0.0.1)
  • 5901 = Port on the remote host (forwarded from the client PC)

To connect to the VNC server, enter the following into the VNC viewer:

or

Remote Port Fowarding for VNC

Figure 2 illustrates remote port forwarding for a VNC session (click to enlarge) over a LAN. The client Windows PC has IP address 192.168.1.1 and the remote Linux PC has IP address 192.168.1.3. The syntax for remote port forwarding as used in this example:

Note: The use of a Windows PC and Linux machine in the Figure 1 below is for illustration purposes only. The operating systems are irrelevant. What matters is that the the client PC has a SSH client and VNC server, and the remote PC has a SSH server and VNC viewer.

To establish the SSH connection using remote port forwarding, the following command could be entered into a command window on the client PC:

  • [email protected] = SSH host to connect to
  • -R = Option to enable remote port forwarding
  • 6999 =Port on the remote host
  • localhost = Host server to connect to (the client PC, same as 127.0.0.1)
  • 5901 = Port on client PC (forwarded from the remote PC)

(Add the “-v” option at the end of the command above to view debugging messages about SSH’s connection progress)

To connect to the VNC server, enter the following into the VNC viewer:

or

If you have found a spelling error, please, notify us by selecting that text and pressing Ctrl+Enter.

My friend wanted to remotely work from school on her laptop. SSH wasn't enough for her, since she wanted to see whole IDE.

Since she is also using Linux (Arch Linux), we decided to use utility called VNC for that. It took me some time to figure out how to set it properly with whole port forwarding, since there is a little trick with that.

Whole process is really (surprisingly) simple!

First we need to set up a server - the computer we want to connect to. In this guide we'll use tigervnc which can be found in repositories of all common linux distributions. It installs both - server and client.

Now just run in terminal:

if this was the first time you run the vncserver, it will ask you for password which you'll use for connection. You can change it later by command vncpasswd.

Your server should be running now. You can kill it by:

and run it again to see if everything is working.

There is a lot of parameters with which is possible to run vncserver. You can find them in manual page or help.

Just for testing purposes we're going to try to connect to the same computer. Find out you internal IP (e.g by ip addr) and type to terminal:

it should ask for the password you entered earlier and after successful authorization new window should pop-up. It'll be probably black and nothing interesting will be seen. Never mind - we'll work on that in a minute :) . If you proceed here, VNC is successfully working and we just need to add some configuration.

We need to run some graphic environment after starting VNC session. VNC has an option for that in file ~/.vnc/xstartup. Make a backup of it and than edit original to your needs. My looks like this:

because I'm using i3 window manager. If you use e.g. xfce4, add exec startxfce4 or you can try just startx.

When you try to login now using vncviewer, graphic environment of your choice should be started.

Again, there is bunch of parameters for vncviewer command, which can be found by reading it's help or manual page.

Here I'll cover how to set up connection from outside of the world. You'll need to know how to do port forwarding on you router.

Remember when we started server by vncserver :1? The last part :1 is where you assign a port to be used for VNC. But the actual port IS NOT that number (number1** in this case). The actual port is 5900 + 1 = 5901. So when you type vncserver :<some_number>, vncserver is listening at 5900 + .

I will continue with an example now. Let's say that our external IP is 12.13.14.15 and our internal IP is 192.168.0.20 and we want to run our VNC on port 12345. vncserver must be run with number equal to 12345-5900=6445.

  1. Run vncserver :6445
  2. Forward port 12345 to 192.168.0.20 (don't change target port range - it's same).
  3. From a computer from which you want to connect type vncviewer 12.13.14.15:12345
Port

and that's it. Hope it helped a little :) .

Good thing to know is that you can display tigervnc menu by pressing F8. It can disable or enable full screen, display some additional info about connection, close connection etc.

Mac vnc port number

Keyboard shortcuts are in this priority:

Vnc On Mac

If shortcut has some action assigned on computer I'm pressing the keys, the action will take effect here. Otherwise, send them to remote computer.