Page 1 of 2

How to add SetEnv in SFTP-settings?

Posted: 2023-07-12, 09:55 UTC
by Spz2022
How to add SetEnv

Re: How to add SetEnv in Sftp ?

Posted: 2023-07-12, 14:34 UTC
by ghisler(Author)
You can now send commands from a button also to the SFTP plugin.
Function type: send shell command
Command: sh <- MUST always be just sh
Parameters: The actual command. Start with ? to get confirmation dialog, start with * to get result as dialog, ?* for both. You can use all placeholders like %N for the first selected file.

Re: How to add SetEnv in Sftp ?

Posted: 2023-07-13, 04:01 UTC
by Spz2022
ghisler(Author) wrote: 2023-07-12, 14:34 UTC You can now send commands from a button also to the SFTP plugin.
Function type: send shell command
Command: sh <- MUST always be just sh
Parameters: The actual command. Start with ? to get confirmation dialog, start with * to get result as dialog, ?* for both. You can use all placeholders like %N for the first selected file.
I mean specifying it on settings, not after connecting.

Re: How to add SetEnv in Sftp ?

Posted: 2023-07-13, 06:40 UTC
by JOUBE
Spz2022 wrote: 2023-07-13, 04:01 UTC
ghisler(Author) wrote: 2023-07-12, 14:34 UTC You can now send commands from a button also to the SFTP plugin.
Function type: send shell command
Command: sh <- MUST always be just sh
Parameters: The actual command. Start with ? to get confirmation dialog, start with * to get result as dialog, ?* for both. You can use all placeholders like %N for the first selected file.
I mean specifying it on settings, not after connecting.
It would be enough for me as described. But how and where exactly do I enter it?

Re: How to add SetEnv in SFTP-settings?

Posted: 2023-07-13, 09:53 UTC
by ghisler(Author)
I mean specifying it on settings, not after connecting.
Unfortunately the plugin doesn't allow to send user commands when connecting, sorry.
It would be enough for me as described. But how and where exactly do I enter it?
Lower button bar: Press the rightmost button. If it opens a secondary button bar, click on the "+" button. Then enter the details as described above.

Re: How to add SetEnv in SFTP-settings?

Posted: 2023-07-14, 16:09 UTC
by Spz2022
This is true, but some ssh needs to be authenticated by
SetEnv.

Re: How to add SetEnv in SFTP-settings?

Posted: 2023-07-17, 10:42 UTC
by ghisler(Author)
Can you give me more details, please? SetEnv just sets an environment variable, what does it have to do with authentication? You can't send shell commands before being logged in!

Re: How to add SetEnv in SFTP-settings?

Posted: 2023-07-25, 07:28 UTC
by Spz2022
like this
ssh -o "SetEnv SECRET=XXX" root@8lgm.segfault.net

Re: How to add SetEnv in SFTP-settings?

Posted: 2023-07-25, 07:45 UTC
by ghisler(Author)
Sorry, I don't see how this would work before logging in. SSH just creates a remote shell, but you can't send commands until you are fully logged in.

Re: How to add SetEnv in SFTP-settings?

Posted: 2023-07-25, 07:59 UTC
by Spz2022

Re: How to add SetEnv in SFTP-settings?

Posted: 2023-07-25, 08:03 UTC
by JOUBE
ghisler(Author) wrote: 2023-07-25, 07:45 UTC Sorry, I don't see how this would work before logging in. SSH just creates a remote shell, but you can't send commands until you are fully logged in.
"ssh -o SetEnv...." is part of standard implementation of ssh: (e.g. https://linuxcommand.org/lc3_man_pages/ssh1.html : -o option). and will be "piped" to ssh *) if you use it with scp -o ... . But if it works with the lib I do not know.

*) and how it is handled than from/between ssh and sshd its there part...

Re: How to add SetEnv in SFTP-settings?

Posted: 2023-07-25, 08:11 UTC
by ghisler(Author)
2JOUBE
What do you mean with "piped to ssh"? To send commands via SSH, you have to open a channel through which you can then send shell commands like setenv. Do you mean that ssh -o SetEnv doesn't need a channel to send commands to the server?

Re: How to add SetEnv in SFTP-settings?

Posted: 2023-07-25, 08:13 UTC
by JOUBE
ghisler(Author) wrote: 2023-07-25, 08:11 UTC 2JOUBE
What do you mean with "piped to ssh"? To send commands via SSH, you have to open a channel through which you can then send shell commands like setenv. Do you mean that ssh -o SetEnv doesn't need a channel to send commands to the server?
As i have written in my edited (at the same time you answered) post: *) and how it is handled than from/between ssh and sshd its there part...

And it is not your part... and it is used IIRC for the separation of different users within the login process.

Re: How to add SetEnv in SFTP-settings?

Posted: 2023-07-25, 08:17 UTC
by ghisler(Author)
I found something in RFC 4254, is it that?
https://datatracker.ietf.org/doc/html/rfc4254#section-6.4

But it also requires a channel as parameter.

Re: How to add SetEnv in SFTP-settings?

Posted: 2023-07-25, 08:21 UTC
by JOUBE
ghisler(Author) wrote: 2023-07-25, 08:17 UTC I found something in RFC 4254, is it that?
https://datatracker.ietf.org/doc/html/rfc4254#section-6.4

But it also requires a channel as parameter.
All this is not your part. You only have to support the -o option. Im not sure this is possible with the lib. Or if you handle the login via the login yourself then you have to check how to handle option "setenv" with the lib. But all the -o options works with ssh itself.