Skip to content

Commit

Permalink
Merge pull request #804 from leszekgrzegorek/remote-ssh-cmd-configurable
Browse files Browse the repository at this point in the history
Make SSH command configurable for remote debug
  • Loading branch information
puremourning authored Oct 3, 2023
2 parents 951c4b2 + 212ae73 commit 94ca1d5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
15 changes: 10 additions & 5 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -836,9 +836,12 @@ Vimspector has in-built support for executing remote debuggers (such as
where the development is done on one host and the runtime is
some other host, account, container, etc.
In order for it to work, you have to set up paswordless SSH between the local
and remote machines/accounts. Then just tell Vimspector how to remotely launch
and/or attach to the app.
In order for it to work, it is preferred to have set up paswordless SSH between
the local and remote machines/accounts. Then just tell Vimspector how to remotely
launch and/or attach to the app. By default, 'ssh' command is being used.
Optionally, the custom ssh command can be specified with cmd property which gives
opportunity to use, e.g. sshpass, for non-interactive password passing to actual
ssh client (see the [Python (debugpy) Example](#python-debugpy-example) below).
This is presented as examples with commentary, as it's a fairly advanced/niche
case. If you're not already familiar with remote debugging tools (such as
Expand Down Expand Up @@ -875,8 +878,9 @@ Vimspector then orchestrates the various tools to set you up.
// If omitted, runCommand(s) is run locally
"account": "${account}", // User to connect as (optional)

// Optional.... Manual additional arguments for ssh
// Optional.... Manual ssh client and additional arguments
// "ssh": {
// "cmd": [ "sshpass", "-p", "pa$$w0rd", "ssh" ],
// "args": [ "-o", "StrictHostKeyChecking=no" ]
// },

Expand Down Expand Up @@ -938,8 +942,9 @@ Vimspector then orchestrates the various tools to set you up.
// /* optional command to run after initialized */
// ]

// Optional.... Manual additional arguments for ssh
// Optional.... Manual ssh client and additional arguments
// "ssh": {
// "cmd": [ "sshpass", "-p", "pa$$w0rd", "ssh" ],
// "args": [ "-o", "StrictHostKeyChecking=no" ]
// },
}
Expand Down
18 changes: 17 additions & 1 deletion docs/schema/vimspector.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,27 @@
},
"host": {
"type": "string",
"description": "Name of the remote host to connect to (via passwordless SSH)."
"description": "Name of the remote host to connect to (via passwordless SSH or with e.g. sshpass if ssh['cmd'] specified)."
},
"container": {
"type": "string",
"description": "Name or container id of the docker run container to connect to (via docker exec). Note the container must already be running (Vimspector will not start it) and it must have the port forwarded to the host if subsequently connecting via a port (for example <tt>docker run -p 8765:8765 -it simple_python</tt>)."
},
"ssh": {
"type": "object",
"description": "Optional to customize the ssh client and its arguments to execute for remote-launch or remote-attach.",
"properties": {
"cmd": {
"type": "array",
"items": { "type": "string" },
"description": "Command to execute SSH client."
},
"args": {
"type": "array",
"items": { "type": "string" },
"description": "SSH client command arguments."
}
}
}
}
},
Expand Down
4 changes: 3 additions & 1 deletion python3/vimspector/debug_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1659,7 +1659,9 @@ def _PrepareLaunch( self, command_line, adapter_config, launch_config ):


def _GetSSHCommand( self, remote ):
ssh = [ 'ssh' ] + remote.get( 'ssh', {} ).get( 'args', [] )
ssh_config = remote.get( 'ssh', {} )
ssh = ssh_config.get( 'cmd', [ 'ssh' ] ) + ssh_config.get( 'args', [] )

if 'account' in remote:
ssh.append( remote[ 'account' ] + '@' + remote[ 'host' ] )
else:
Expand Down

0 comments on commit 94ca1d5

Please sign in to comment.