Skip to main content
edited title
Link
terdon
  • 252.7k
  • 69
  • 481
  • 719

Gettin Getting a pid for an ssh process that backgrounded itself

Source Link
dlamblin
  • 463
  • 1
  • 5
  • 12

Gettin a pid for an ssh process that backgrounded itself

So I wanted to call two background ssh processes:

ssh -D localhost:8087 -fN aws-gateway-vpc1 ssh -D localhost:8088 -fN aws-gateway-vpc2 

These gateways don't have the benefit of letting me set an authorized_keys file, so I must be prompted for my interactive password. That is why I'm using the -f flag and not the shell's & which will only background the process after I authenticate interactively.

In this scenario I appear to be unable to use the $! bash variable to get the pid of the recently [self] backgrounded process.

What other options do I have to find the correct pid to kill later if interrupted?