openssh-rust / openssh

Scriptable SSH through OpenSSH in Rust
Apache License 2.0
232 stars 35 forks source link

[Feature request] Allow to specify ENV for the command #145

Open Dzordzu opened 7 months ago

Dzordzu commented 7 months ago

Description

Allow to set env during command sending process

Current behavior

Error, as specified in the docs

OP help

Unfortunately, not possible as of now

NobodyXu commented 7 months ago

Thanks for reporting, bit busy and will investigate later.

Do you know that you can use tempfile plus the openssh::Builder to override the ssh-config and specify the env within it?

While it's a stop-gap solution, it might be handy if you need it.

Dzordzu commented 7 months ago

Do you know that you can use tempfile plus the openssh::Builder to override the ssh-config and specify the env within it?

I know it. Unfortunately the env is different for every command :/

NobodyXu commented 7 months ago

Hmmm seems that you would definitely need openssh support for this.

As an alternative, you can change command to be run to env, then pass env as A=B, then pass the original cmd and args.

Dzordzu commented 7 months ago

As an alternative, you can change command to be run to env, then pass env as A=B

I've been aware of this option. Overall it could be a solution. On the other hand I consider it as a huge, dreadful hack. At least doing it manually. It either requires me to write an additional wrapper around library, or perform these changes on every command execution. Both of these options are... I don't like them xD

NobodyXu commented 7 months ago

I agree, I will investigate to see if there's better solution.