Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
after login in I forward a port from our front end to a node like this:
Code:
fe$ ~C <enter>
-L XXXX:node:YYYY
fe$
so far I have been loging out of the ssh session to remove that port forward. Is there a command to do so, so I won't have to log out? I really just want to redirect the remote end (node:YYYY) to a different node.
lol rweaver has a sense of humor. actually it won't log you out when you kill ssh... it will just cause connection drop
wondering about this too...
--upd:
no way I just built the latest ssh 5.3p1 from sources: they just added -D param in that ~C menu.
you know what... it looks like simply not supported.
here's some code(clientloop.c:810, 5.3p1)
Code:
if (*s == 'K') {
delete = 1;
s++;
}
if (*s == 'L')
local = 1;
else if (*s == 'R')
remote = 1;
else if (*s == 'D')
dynamic = 1;
else {
logit("Invalid command.");
goto out;
}
if ((local || dynamic) && delete) {
logit("Not supported.");
goto out;
}
probably there is a way around if try to hack the code...
I'm not a good C coder but from here it looks like to get this to work we have to list existing port forwarding "channels", find one listening that local port and destroy it in channel_setup_fwd_listen() function before calling bind() and listen() etc.
Like it's done here: (channels.c:2630, 5.3p1)
Code:
int
channel_cancel_rport_listener(const char *host, u_short port)
{
u_int i;
int found = 0;
for (i = 0; i < channels_alloc; i++) {
Channel *c = channels[i];
if (c != NULL && c->type == SSH_CHANNEL_RPORT_LISTENER &&
strcmp(c->path, host) == 0 && c->listening_port == port) {
debug2("%s: close channel %d", __func__, i);
channel_free(c);
found = 1;
}
}
return (found);
}
i'm now really curious about this, maybe I can add this little improvement. I'll go try this out by now.
santana you may either use -D parameter in SSH(since 5.2) or you can look here for alternate solution I've cooked today
It's a sort of solution, anyways, I don't guarantee it's going to work in your case but still might be useful.
The long and short answer is without resetting the ssh session (at least on the versions I have access to (5.1.x)) there is no way to kill an existing tunnel you created. I think the answer offered by web31337 is as good an answer as you're going to find. I also think it would be something worthwhile to suggest to the openssh developers... there IS a way to do it with the protocol because you can do it with putty for instance connected to an openssh server... but I can't find a good way to do it with the command line version of the openssh client.
Probably the one I suggest is the very method of doing that. At least it seem to be logically correct in code. I can't see a reason why such a simple thing was not implemented in OpenSSH while it is added in PuTTY.
Tunnel appears to be freed correctly(at least debug messages say that, and it just works as meant to), but there are still things I have to add, but not now.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.