I recently used the command
ssh -C2qTnN -D 19002 user@host
on my VPS where user and host are respectively my username and VPS ip of course.
Then I used putty (used the Connection -> SSH -> Tunnels option) to set up a "Dynamic" destination and a source port. I also changed my browser's proxy settings accordingly. Everything worked fine.

However I want to know if this command can be reverted/reversed ? I mean if I can set the system back to what it was before I issued the above command. Does it create a background process ? How can I stop SSH on my VPS from forwarding/listening at port 19002 ?

When I use
ps -ax | grep ssh
I see two results:
24505 ? Ss 0:00 sshd: user[priv]
24509 ? S 0:00 sshd: user@pts/0
Killing any of them just closes/disconnects my remote SSH session so I'm guessing they have nothing to do with the tunnel ?

From what I gathered on the net about the -C2qTnN parameters:
-C Requests compression of all data (including stdin, stdout, stderr, and data for forwarded X11 and TCP/IP connections)
-2 Forces ssh to try protocol version 2 only.
-q Quiet mode. Causes all warning and diagnostic messages to be suppressed.
-T Disable pseudo-tty allocation.
-n Redirects stdin from /dev/null (actually, prevents reading from stdin). This must be used when ssh is run in the background.
-N Do not execute a remote command. This is useful for just forwarding ports (protocol version 2 only).

Thanks all.
yea you can stop ssh tunneling easily

Debain/Ubuntu

Grant Root Access or "sudo" access

Go to your ssh settings using any editor you like instead of pico

pico /etc/ssh/sshd_config
then search for this in the config AllowTcpForwarding
if not found add it and the end of the config

and set it for
AllowTcpForwarding no
then restart the ssh and disconnect the old tunnels and try
service ssh restart
Thanks.
But the problem is, as soon as I set "AllowTCPForwarding" back to yes (or I comment it out) I can tunnel via port 19002 again.
I need a way to permanently undo the command I mentioned in my original post. There was no tunneling through port 19002.
Just assume I want to stop tunneling through that port and/or change it to another.

What's weird is that even
netstat -tuwlpn | grep 19002
doesn't show anything at all.
How can I stop SSH on my VPS from forwarding/listening at port 19002 ?
It is my understanding that -D 19002 opens a dynamic port on your local computer rather than the server. The way to "undo" the command is simply to kill the SSH process (which I assume you have already done).
Yes but, since I was confused about it before, I typed it on the remote Linux server. My local machine is just running Windows 7.
Anyway, thanks for the answers and sorry for the silly questions. Just started learning about Linux and I am sure I have a lot more reading/practice to do.
In order to tunnel with putty, all you have to do is just go to Connection=> SSH => Tunnel, and configure the proxy in your browser/app afterwards. Once you close putty or disconnect, the tunnel will be gone.

I didn't quite get the command thing, you're using putty, so you're on windows, but you ran that command somewhere, so I'm guessing you ran it on your server.
ssh -C2qTnN -D 19002 user@host
You basically SSHed from your server to your server, and created a tunnel from your server to your server.
@Hybrid, indeed... which was a useless move. I see that now.
My question is: The SSH command I inadvertently ran on my server must have created a process right ? Why can't I find it to kill it ? I am also guessing that the process isn't there since I had to reboot and I didn't add it to /etc/rc.d.
DG wrote@Hybrid, indeed... which was a useless move. I see that now.
My question is: The SSH command I inadvertently ran on my server must have created a process right ? Why can't I find it to kill it ? I am also guessing that the process isn't there since I had to reboot and I didn't add it to /etc/rc.d.
True, but it should be gone if you restarted your server or sshd
@DG: The process was probably killed before you rebooted. Most likely after the first time you disconnected. Every time you enter a command, your shell will fork a new process. This new process will have the PID of your shell marked as parent. When you kill a process it will send a SIGHUP signal to all its children. ssh, lime most standard unix programs, will exit cleanly upon receiving a SIGHUP.

In your case here's what most likely happened. When you disconnected from the server (by closing PuTTy for instance), you killed your shell instance that in turn sent a SIGHUP to the ssh process running. The ssh process did not survive your disconnection. Of course if you reboot it wouldn't have survived either.

You can tell a program to ignore SIGHUP by using the nohup command, or even better use a console multiplexer like screen.

/etc/rc.d is reserved for services you want started automatically upon reboot (which might not be the case), and depending on the unix flavor you're using, be aware that these scripts are probably going to be replaced by systemd soon. (Well, most linux distros anyway).

I hope this answers your question and please ask if anything's unclear.
you can run:
mycommand & disown
Then the 'mycommand' process won't be killed when you exit the shell.
Thanks guys. I got my answer. Yes that's what I'm doing for the rtorrent process (using screen).
I'm running CentOS 6.0 by the way and I like it.

I had an idea how process forking works but I checked again on Wikipedia:
For a process to start the execution of a different program, it first forks to create a copy of itself. Then, the copy, called the "child process", calls the exec system call to overlay itself with the other program: it ceases execution of its former program in favor of the other.
Thx everyone (Prince, Samer, Hybrid, Rahmu and Hussam).

Rhamu, I've got another question that I'll ask in a new thread if you don't mind.