An elegant way to control a bunch of ssh connections

Lets say you want to establish ssh tunnel and put it into background: ssh -fNL 12345:localhost:54321 user@remote When you are done using tunnel you could use: pkill -f "ssh -fNL 12345:localhost:54321 user@remote" but it just doesn’t look right :) Things get a lot more messy when you need to have a bunch of ssh sessions. Lets say you have some client program and server program, and you want to use ssh to tunnel a connection from host1 to host2....

November 28, 2014 · 3 min · 535 words · Ruslan Kuprieiev

How to set PID using ns_last_pid

So there is this cool project called CRIU (Checkpoint/Restore In Userspace). And I was wondering how it gets certain PID when restoring a process. I always thought that it is not possible to set PID without some kind of kernel hacking. I did some investigation and here is what I figured out. There is a file /proc/sys/kernel/ns_last_pid, which contains the last PID that was assigned by the kernel. So, when the kernel needs to assign a new one, it looks into ns_last_pid, gets last_pid, and assigns last_pid + 1....

June 14, 2014 · 2 min · 338 words · Ruslan Kuprieiev