This works perfectly. It's not the simplest way, as you say, but it does the job!
Not understanding a word of code for this, what's the obstacle for making secure shell-function work like doors? I.e. you can just stack as many as you want in the same "secure shell"-function and it will just add more buttons in terminal.