With a little help from my friends....

I finally figured this out. (Thanks to the stout-drinking fellowship of
BLUG for the advices that solved the mystery!)
Well I might as well post a description, with the slight possibility it could be useful for someone else:
Kind of half-baked tutorial...OK. What I want to do is to be able to sit at a computer AWAY (anywhere on the internet) and control my stream that's played by foobar2000 and streamed out by Icecast2 from my computer HOME. I can control fb2k playback with foo_controlserver, but since it's over the internet I want a secure channel so that noone else can hijack my stream.
Well first I have fb2k up and running with foo_controlserver listening on port 3333 (where it listens by default, look in Preferences to change). I now have to CLOSE port 3333 and OPEN port 22 (SSH server listens on port 22) in the firewall that separates my machine HOME/my private network from the internet. This is essential!
Then I have to set up the SSH server. In my case I chose to set it up on my computer HOME where fb2k, the Icecast2 server and the music files resides. I'm running XPsp1 on HOME. Therfore I chose the minimal Cygwin installation of OpenSSH as linked to in the post above. (Later I'm gonna build a dedicated SSH server box for my private network that's gonna run on some true Linux/BSD, but I haven't gotten that far yet.) Installation and setup of different SSH servers might differ, so read the manual.
In my case (using
SSHWindows) it was simply a matter of running the installer, then create the
group and
passwd files in /etc/. This is very well described in
readme.txt in /docs/, so I won't go any closer into it here.
EDIT: On second thought, since this have turned into a kind of newbie tutorial, I will give the example of how I did it anyways (in my example I use the -l switch for local, you can also use, or replace it with, the -d switch for domain. If you use both you must edit out duplicate lines afterwards. For me running -l was enough). OK. Let's set it up for user "joefoo":
First you must open a command prompt (Run > cmd.exe). Then you must CD into "installpath"\OpenSSH\bin and run first this command:
CODE
mkgroup -l >> ..\etc\group
and then this command:
CODE
mkpasswd -l -u joefoo >> ..\etc\passwd
NOTE: If you will use SSHWindows, you must specify user and password for the account (e.g. "joefoo") that you want to use in Windows own Controlpanel > User Accounts
before creating the group and passwd files if your gonna have a password (if you havent done so already). (It's possible that you can use keypairs and such instead, in that case you'll have to read up on it yourself.)
NOTE2: SSHWindows will choke if there are more than one instance of cygwin1.dll in %PATH%. Use SEARCH and delete the older one(s) to remedy this. SSHWindows will also choke if you have the regular
Cygwin installation installed on your box. In that case use their OpenSSH server instead. Also: you should check if
quietcmd.bat found in /bin/ have the right path to cmd.exe. On my XP box it was wrong ("c:\winnt\system32" instead of "c:\windows\system32"). Edit if necessary.
IMPORTANT: Now you'll have to edit the
sshd_config file found in /etc/ and uncomment the line "AllowTcpForwarding yes" (this will look fairly the same on all SSH servers I think). This option MUST be enabled! There are also other options in that configfile that might be of interest (like "ClientAliveInterval"?). For further explanation of the meaning of the switches you can look e.g.
here.
ELABORATION: "edit" means with notepad or any text editor. Preferably something like
Vim or
EditPlus that, unlike notepad, will display the file correctly and respect it's native format when saving it back (it's those Unix - Windows LF - CR/LF line ending issues again...). And make sure no extension are added to the file when saving it back!
"uncomment" means remove the # from the beginning of a line to make it active.
"/etc/" means the directory named
etc in the Unix-structure of the installation.
Then you simply have to start the SSH server. For me that meant typing in "net start opensshd" at Command Promt. Or making batch files:
CODE
@echo off
net start opensshd
pause
exit
CODE
@echo off
net stop opensshd
pause
exit
In other SSH server implementations much might be different (?)
-------------------------------------------
Well. Then I leave the house and go traveling. Suddenly I'm sitting by the machine AWAY. AWAY is a Windows machine and I'm gonna use
PuTTY as the client program.
First you start one Putty session. In the startup panel under Session you simply choose Protocol "SSH", Port "22" and in the Host Name field you'll have to enter HOME's IP or domain name (in my case a
DynDNS domain), e.g. "joefoo.dnsalias.com".
Then you'll have to go to Connection > SSH > Tunnels > Port forwarding:
Of the switches Local/Remote/Dynamic choose "Local".
In Source port enter: "3333"
[without the quotes - that goes for all of this] (BTW: you can choose any arbitrary port really. It must be higher than 1024, and should be above 3000).
In Destination enter: "localhost:3333" (or whatever port foo_controlserver are listening on at HOME. It must be higher than 1024, and should be above 3000. If foo_controlserver sits on a different machine than the SSH server on your local network you must enter the local network IP for the machine foo_controlserver sits on instead of localhost, e.g. "10.0.0.4:3333").
In some cases, if e.g. more than two machines are involved you might have to tick one or both of the "Local ports accept connections from other hosts" and "Remote ports do the same" options in order to make it work. Experiment, or just tick them both to be on the safe (but maybe not quite as secure???) side....
Now you MUST remember to click "Add", so that you see the field:
QUOTE
L3333 localhost:3333
Then you can just press "Open" to start the session. Log on to HOME the usual way (username, password and such). Then if you click in uppermost left corner of PuTTY window you can choose "Event log" to check whether the tunnel really are established. You should see something like this in there:
QUOTE
2004-06-19 18:47:19 Local port 3333 forwarding to localhost:3333
Now just start a
second PuTTY session and minimize (not close!) the first PuTTY session window.
In the new startup panel, under "Session" choose:
Hostname "localhost" Protocol "Telnet" Port "3333" (Or whatever port you earlier specified for "Source port").
Other options you might want to take a look at:
Connection; Seconds beween keepalives: I set this to 30. If you don't enter anything here your connection will get killed after a while, and you must logon again.
Connection > Telnet:
Unchecking "Return key sends telnet New Line instead of ^M"
seems to improve on foo_controlservers ability to take orders....
Window; Lines of scrollback: How long are your playlist? I just as well sat this to 10000.
Window > Translation: If you want those non-ASCII characters in your playlist to display correctly, choose UTF-8.
Window > Apperance: Font?
(Under PuTTY menu you can also change these settings during session with "Change settings...")
Now just press "Open", and TADA! youre logged onto foo_controlserver through a secure tunnel over the internet!