pkg / sftp

SFTP support for the go.crypto/ssh package
BSD 2-Clause "Simplified" License
1.5k stars 380 forks source link

site exec #453

Closed fdefilippo closed 3 years ago

fdefilippo commented 3 years ago

hi, I would like to implement some kind of site exec so that I can execute a command like below:

exec /path/to/myprogram args

is there any example from which to draw inspiration?

thank you.

puellanivis commented 3 years ago

As far as I am aware the SFTP protocol offers no such functionality.

Since packets are bundled into discrete function packets, and we are not simply exchanging text commands, there is not really a way to do this sort of thing without using some special SSH_FXP_EXTENDED packets, and as of now, we have no way to support custom extended packets.

drakkan commented 3 years ago

@fdefilippo this can be easily done using the SSH protocol.

You can add an handler for the exec req.Type here for example.

fdefilippo commented 3 years ago

Thank you.

drakkan commented 3 years ago

@fdefilippo the above answer is to handle commands server side (within a Go SSH server). If you want to execute a command from a Go client application to a generic SSH server you can use something like this