1

I have access to four computers:
1 Ubuntu Server desktop (Version 10.04)
1 Mac Mini (Snow Leopard)
1 Windows desktop (Windows 7)
1 Windows laptop (Windows Vista)

The first three will always be on the home network. My goal is to SSH from the laptop into the server and be able, through VNC (or another remote desktop software), to control the windows and mac computers. The goal of this would be a slightly heightened network security over using VNC to directly access the mac or windows desktop.

I have successfully used SSH to connect to the server, but have not been able to successfully implement the remote desktop connection. I would appreciate help doing so. Here's what I've done so far:

As per instructions here: http://www.stuartellis.eu/articles/vnc-on-linux/ I installed the following:

  • vnc4server – the main VNC server software
  • vnc-java – enables access from Web browsers with Java support
  • xvnc4viewer – a basic VNC viewer

I then set up a password using the vncpasswd command. To attempt to connect to the mac, I followed directions I found in a thread at superuser. com and went to "System Preferences>Sharing" and enabled "Screen Sharing".

Subsequently, I tried entering the following commands into Ubuntu:
vncviewer mac_ip_address::5904 vncviewer mac_ip_address:0 vncviewer mac_ip_address:1

They all returned the following:
VNC Viewer Free Edition 4.1.1 for X - built Apr 9 2010 18:41:55
Copyright (C) 2002-2005 RealVNC Ltd.
See http ://www .realvnc. com for information on VNC.
vncviewer: unable to open display ""

I'm sure I'm missing something important, but I'm not sure what it is. Do I need to have a GUI installed, or did that come with the vnc packages I installed?

2 Answers 2

2

I'd suggest a better idea would be to use the built in functionality in ssh to tunnel/port forward some local ports on through your ssh client to the destination host, and use rdp on the windows boxes, and vnc on mac.

For the linux host, if you want graphical access to it, i'd suggest no machine (NX).

1
  • Is the solution still up to date?
    – Mircea
    Jul 23, 2018 at 11:24
1

I'm a little confused about your process. Are you connecting to the Ubuntu system through SSH and then typing in vncserver on the ubuntu server that you are ssh'd into?

If that is the case, then as the error message suggests, your command line SSH session is unable to open up a GUI to display your vnc connection for you. I believe you will need to use a VNC client on your laptop in order to connect to the Windows or Mac computers.

I'm assuming that the three home computers are behind a router or firewall or something and you just have ssh opened up for your ubuntu system.

As fenix said, you can use ssh port forwarding in order to make one of the ports on the Ubuntu system behave just as if it were a port on the Mac or Windows systems (Ubuntu must have access to the ports). You would have to forward another port in the router to point at Ubuntu so you can use it for VNC. Once you set up the tunnel, VNCing to Ubuntu on the port that you set up will connect you to whatever machine you specified in the ssh tunnel.

You could just directly forward the ports in the router or firewall to point at the servers and then directly connect to the servers using vnc over the internet... but this is generally considered a huge security risk.

Let me know if any of my assumptions about what your trying to do were incorrect.

Edit: so you have ubuntu server, mac mini, and windows behind the router. You have ssh access to the ubuntu server.

Now with your laptop, from outside your internal network, open up putty. Type in all the info for the session (hostname and such). On the left side scroll down to Connection -> SSH -> Tunnels

set source port to some port that probably is not in use (like 5000). Set the destination to whatever system on the remote side that you want to connect (the internal IP and port). For example localhost:5900 would give you vnc access to your Ubuntu server that is serving the ssh. The next row of radio buttons should be set to "local" and the next row to "auto". Now click "add" and then "open".

With these settings in putty on your laptop, you have an open tunnel from your laptop at port 5000 to the remote computer at port 5900 (vnc port). Now on your laptop you should be able to open a vnc connection to "localhost:5000" (your laptop loop-back at port 5000) and it should connect you to the Ubuntu vnc session.

On a side note, make sure you are running a program like fail2ban or denyhosts on your ssh server so that you dont get hacked with a brute force attack.

3
  • Thanks for the responses. I first tried entering 'vncviewer' on the ubuntu server through SSH, like you said. When that didn't work, I tried entering the command directly into the server (sitting at the computer and typing it in) and it returned exactly the same thing. That said, I'll try port forwarding and see what comes up. Thanks again for the responses!
    – user45489
    Jun 12, 2010 at 1:14
  • By the way, I tried connecting to the mac from the windows computer using tightvnc, and it worked. So I know that the only problem (so far) is the connection between the ubuntu server and the mac. As stated above, SSH is not the issue currently. I'm new to servers and ubuntu, so I'm not entirely sure what you are suggesting I do with the port forwarding. Will vncviewer not enable the server to access the mac's (or PC's) desktop?
    – user45489
    Jun 13, 2010 at 20:14
  • @user45489 I updated my answer. Please take a look.
    – James T
    Jan 30, 2011 at 9:25

You must log in to answer this question.