X Forwarding and/or SSH into my home?

Hi there, I recently bought a laptop, and while when I’m at home I can connect to my PC , I’d like to be able to do this from abroad too, even, if possible, to control my PC from my laptop as well (This is where the X Forwarding comes in)

Anyway, my PC runs OpenSUSE 11.2 KDE, and my laptop is running Kubuntu 9.10.

My PC at home resides inside of a network to which I am the administrator, and has a static IP address.

I DO NOT have a web server, is this required? Or can I simply connect to my external IP address?

Anyway, if the above is possible, then how I would I tell my ssh to go to the right internal IP address?

And of course, is it possible to forward my X session at home to my laptop and remotely control my PC?


LAN example:
ssh -X LostChild1@

I don’t know about over the net. I guess you will need to open your router port for this too and make darn sure you have it rock solid secure!!

Wait on more knowledgeable advice…

I have this set up and working. If you have a static external IP then you don’t need to use a dynamic DNS service, so that saves the first task. Second is to configure your router to forward the SSH port (default is 22) to your desktop. For this to work you need a new-ish router that supports port forwarding based on MAC address, or to take your PC off DHCP and use a fixed internal IP, then forward ports to that. I used to do the fixed internal IP, now I have a newer router so use the MAC address option.

Thirdly ensure any firewalls have these ports opened.

That will allow you to open an SSH connection from your laptop to your PC, giving you command line access to your desktop. You configure this to tunnel the VNC port (default 5900) so VNC is secure. Forward that port too.

From the command line you can open X11 VNC server to listen on localhost port 5900 (what you tunelled before). The first time it runs you set a password. Once that’s running you use vncviewer on your laptop and point it at localhost::5900, everything should work from there.

Okay, so I’m having a bit of a hard time understanding completely… Here’s where I am…

I can successfully SSH into my home machine using the command caf4926 gave me or just by doing “ssh [external IP]”.

I have tightvnc on both PCs, and I have X11VNC on my home PC and vncviewer on my laptop.

I seem to get stuck here:

"You configure this to tunnel the VNC port (default 5900) so VNC is secure. Forward that port too.

From the command line you can open X11 VNC server to listen on localhost port 5900 (what you tunelled before)."

Do I do the “tunneling” when I issue my ssh command from my laptop to my PC? How do I do that?

Also, do I then setup X11VNC using my ssh connection from my laptop to my PC? Or should I like, leave X11VNC on before I know I’m leaving the house?

Tunnelling: these are my commands:

alias ssh2pc=“ssh -C myaccount.dyndns.org -p 22 -L5900:localhost:5900 -p 22 -l myloginid”

alias vnc2pc=“vncviewer localhost:5900 -encodings Tight -quality 4 -compresslevel 5”

alias startvncserveronpc=“x11vnc -display :0 -usepw -localhost -forever -httpport 5800 -rfbport 5900”

forwards ports 22 and 5900 to the MAC address of my PC. Firewall has these ports open.

It is not necessary to start the VNC server on the PC before leaving it, provided you’ve done it once to set the vnc password.

Okay, so this is what I’m doing now:

I ran your ssh2pc command (Obviously substituting in my own values) from my LAPTOP, which presents me with the command line of my DESKTOP. From there I ran the startvncserveronpc so that it would, well, start the vnc server on my DESKTOP. Then, I opened a new Konsole, and ran your vnc2pc command (Again, substituting your values for mine) (And always leaving parts where you write “localhost” as localhost, I wasn’t sure if I had to change these)

Anyway, the vnc2pc command tell me it’s trying to connect to “localhost:11800” which doesn’t sound right at all, I enter my password, and it gives me a bunch of Java errors, and tells me
that it can’t connect :stuck_out_tongue:

And if I run vnc2pc while still in my DESKTOP Command Line, I get “Error: Can’t open display”

(I’m only capitalizing Desktop and Laptop to try and make it clear where I’m doing what. Also, thanks for the help and step-by-steps. :))

Ah, but if I remove the 5900 from the vnc2pc command, and run it from my laptop, it works fine. As a matter of fact, I’m writing this from my laptop now :stuck_out_tongue:

Yeah, that’s fine since the default port of 5900 is assumed if you don’t specify it. I’ll have a look at what’s wrong with my command when at my PC.

Anyway, thanks again for the step by step instructions, I really appreciate it. :slight_smile: I wonder how well this will end up working on my school’s network… I guess I’ll find out. :stuck_out_tongue:

For the benefit of others who may read this thread, the commands I’ve given are correct for when a non-standard VNC port is used.

Okay, so all of a sudden this has stopped working. :frowning:

At first I was getting an error that

-httpport:5800 -rfbport:5900

weren’t real options. So I read the man, and removed the colon which made it work again. Except I can’t even seem to ssh into my PC (Even though nothing along those lines has changed)

With a “Cannot connect to port 22” thing.

Between then and now I’ve switch my router from a WRT54G2 to a WRT300N both running DD-WRT. But the first thing I did was re-forward my ports for ssh and vnc (22 and 5900 respectively) to my desktops internal IP. So I’m really not seeing what went wrong here. :frowning:


Look at using NX (the one from nomachine.com it’s free) then you only
need ssh open, plus I would move it externally to another port (eg
10222) and for that to 22 on the target machine.

Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel
up 6 days 0:02, 4 users, load average: 0.05, 0.08, 0.08
GPU GeForce 8600 GTS Silent - CUDA Driver Version: 190.18