I would like to modify my existing SSH connection via a shell script. So if I run an existing script remotely I would like it to open a new port to be tunnelled.
Interactively I can do this via:
ubuntu@6c1a17c3864c:~$ ~C ssh> -R 9000:localhost:9000
As put much more clearly than I could: https://unix.stackexchange.com/questions/33557/using-an-already-established-ssh-channel.
Ideally I would like to use a shell script to interact via the escaped characters to adjust the existing connection.
I have looked at something like:
#!/bin/bash # Attempt 1 echo -n '\r\f \~\~C -L 9000:localhost:9000' # Attempt 2 echo -e '\r\f\~\C -R 9000:localhost:9000' printf '\~\C -L 9000:localhost:9000' netstat -taln
As well as a few other combinations.
I have verified that both echo and printf are shell builtins.
I'm using Bash 4.3.11 x86_64-pc-linux-gnu.