By enabling pseudo-terminal with
-t you can sudo into your root shell immediately.
$ ssh -t ansible@centos8 sudo -i X11 forwarding request failed on channel 0 [root@centos8 ~]#
This will start and stop SOCKS proxies with SSH in a daemon like fashion.
ssh \ -f \ # Move ssh into background -N \ # Don't execute remote commands -M \ # Run ssh in "master" mode. This enables sending multiple commands over one session -S ~/.ssh/%C.sock \ # Control Socket for the session -D $PORT \ # Port for dynamic Port App Portforwarding aka SOCKS proxy port $SSH # SOCKS proxy Host
ssh \ -S ~/.ssh/%C.sock \ # Control Socket for the session -O exit \ # Command send over Control socket $SSH # SOCKS proxy Host
Last update: September 8, 2021