Search code examples
sshwindows-subsystem-for-linuxwindows-terminal

Windows terminal - Script opening panes and SSHing to servers


I'm currently using Windows Terminal to front WSL 2 Ubuntu. I use it to SSH out to multiple servers. I'm now at a point where I'd need to run similar \ identical tasks across multiple servers, so I'd like to be able to say Open a new pane and SSH to server Foo, Bar and FooBar. I've got the server config stored in .ssh/config and SSH key access sorted.

Is this possible? Using Powershell isn't an option thanks to overly restrictive IT policies and I'm not expecting much from the old CMD.


Solution

  • if you put this on the "actions": block in the windows terminal settings.json, it will add a keybinding that creates a tab with 3 ssh connections (will also create an entry on the command Pallet(ctrl+shift+p) called servers), you will have to type the commands in each one of them for now, but Windows terminal has a feature coming where you will be able to "broadcast" the keystrokes to multiple panes.

    {
        "command":
            {
                "action":"wt",
                "commandline":"new-tab wsl ssh 'sv1';split-pane wsl ssh 'sv2';split-pane wsl ssh 'sv3'"
            },
    
    
        "keys":"alt+s",
        "name":"servers"
    },
    

    docs: actions commandline args