Hi, on my laptop I use a script that launches several lines like this to connect to my home server: exec ssh -L 127.0.0.1:60000:192.168.X.Y:80 -N user@host & It works fine. The problem is killing that connection. What I do is "killall ssh", but perhaps there is another way I have not thought about? I mean, kill that ssh session and not another? -- Cheers / Saludos, Carlos E. R. (from openSUSE 15.0 (Legolas))
On 11/16/2018 2:22 PM, Carlos E. R. wrote:
Hi,
on my laptop I use a script that launches several lines like this to connect to my home server:
exec ssh -L 127.0.0.1:60000:192.168.X.Y:80 -N user@host &
It works fine. The problem is killing that connection. What I do is "killall ssh", but perhaps there is another way I have not thought about? I mean, kill that ssh session and not another?
Many ways, but if you lose the 'exec' and '&', you could launch a new terminal with each ssh session. When you want to close that one session, close the terminal holding it open. Now there are plenty of alternative ways -- could have a launch writte in shell or whatever that would keep track of which ones were running or not. Then you could select the session you want to kill from a menu in that script. You could just close that connection (control-d in the remote terminal session)... Etc, etc...boils down to how much work one is willing to put in to set it up and what type of overhead you can handle. -l -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Op zaterdag 17 november 2018 17:14:09 CET schreef L A Walsh:
On 11/16/2018 2:22 PM, Carlos E. R. wrote:
Hi,
on my laptop I use a script that launches several lines like this to
connect to my home server: exec ssh -L 127.0.0.1:60000:192.168.X.Y:80 -N user@host &
It works fine. The problem is killing that connection. What I do is "killall ssh", but perhaps there is another way I have not thought about? I mean, kill that ssh session and not another?
Many ways, but if you lose the 'exec' and '&', you could launch a new terminal with each ssh session. When you want to close that one session, close the terminal holding it open.
And use f.e. yakuake ( a dropdown terminal ) and open ( and close ) a new tab for each session, easily see what is going on and close a session by closing the tab. AFAIK konsole has some similar features.
Now there are plenty of alternative ways -- could have a launch writte in shell or whatever that would keep track of which ones were running or not. Then you could select the session you want to kill from a menu in that script.
You could just close that connection (control-d in the remote terminal session)...
Etc, etc...boils down to how much work one is willing to put in to set it up and what type of overhead you can handle.
-l
-- Gertjan Lettink a.k.a. Knurpht openSUSE Board Member openSUSE Forums Team -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2018-11-16 23:22, Carlos E. R. wrote:
Hi,
on my laptop I use a script that launches several lines like this to connect to my home server:
exec ssh -L 127.0.0.1:60000:192.168.X.Y:80 -N user@host &
It works fine. The problem is killing that connection. What I do is "killall ssh", but perhaps there is another way I have not thought about? I mean, kill that ssh session and not another?
You could create a link for every ssh tunnel. Something that uniquely identifies the tunnel. # ln -s /usr/bin/ssh /usr/bin/ssh_192.168.X.Y $ exec ssh_192.168.X.Y -L 127.0.0.1:60000:192.168.X.Y:80 -N user@host & $ killall ssh_192.168.X.Y -- /bengan -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 16.11.18 23:22, Carlos E. R. wrote:
Hi,
on my laptop I use a script that launches several lines like this to connect to my home server:
exec ssh -L 127.0.0.1:60000:192.168.X.Y:80 -N user@host &
It works fine. The problem is killing that connection. What I do is "killall ssh", but perhaps there is another way I have not thought about? I mean, kill that ssh session and not another?
Add the line echo $! to your script directy after that line. This is the PID of ssh you can kill later.
On 17/11/2018 21.59, Florian Gleixner wrote:
On 16.11.18 23:22, Carlos E. R. wrote:
Hi,
on my laptop I use a script that launches several lines like this to connect to my home server:
exec ssh -L 127.0.0.1:60000:192.168.X.Y:80 -N user@host &
It works fine. The problem is killing that connection. What I do is "killall ssh", but perhaps there is another way I have not thought about? I mean, kill that ssh session and not another?
Add the line
echo $!
to your script directy after that line. This is the PID of ssh you can kill later.
Oh! Of course :-) I had forgotten about that. The PID can be saved to a file, and then another script can be used to kill them, without tying any terminal or process. Thanks, all :-) Launching a terminal for each one was the idea I had thought about but discarded, too many terminals already. The symlink idea is interesting, very easy to implement. -- Cheers / Saludos, Carlos E. R. (from 42.3 x86_64 "Malachite" at Telcontar)
participants (5)
-
Bengt Gördén
-
Carlos E. R.
-
Florian Gleixner
-
Knurpht-openSUSE
-
L A Walsh