Skip to content

Without resorting to 'killall ssh', how do I terminate an ssh process running in the background (using the '-f' switch)?

I connect to my computer at work using a tunnel. Here's how I open the tunnel to my machine through the gateway server:

ssh -fNL 12345:my_machine:22 my_login@gateway_server

This opens the tunnel and goes into the background. I then connect to my machine by ssh -p 12345 my_local_\login@localhost. Everything works great.

However, if after getting my work done, how do I close the tunnel I opened in the background? So far, I've been using 'killall ssh' or (if I have multiple ssh connections in progress, kill pid, but is there a simpler way to terminate a ssh process running in the background?

0 points0 comments
Open on Reddit
About this post
Posted
Archived
Score
0 · 100% up
Kind
Text
ID
datlb

Author

2
posts
184
comments
0
media
View profile
Nobody had commented when we saved it.

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.