Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSH Client sending environment variable #1337

Closed
rgillan opened this issue Oct 24, 2023 · 5 comments
Closed

SSH Client sending environment variable #1337

rgillan opened this issue Oct 24, 2023 · 5 comments
Labels

Comments

@rgillan
Copy link

rgillan commented Oct 24, 2023

Server side (ssh2) we are processing the session.on 'env' and using it to transfer required information to our server. This works well from a typical ssh command line. We are trying to create a ssh2 client passing the key information (working) but do not see any methods or ways to send the environment key/value to the server (to emulate the -o SendEnv=X_ENVIRONMENT_VARIABLE ssh option). Is this possible using the ssh2/client?

@mscdex
Copy link
Owner

mscdex commented Oct 24, 2023

You pass them in the options object to shell() or exec() on the client side.

@rgillan
Copy link
Author

rgillan commented Oct 24, 2023

thanks, bit of trial and error and we are passing it correctly. We needed to have:
client.shell({"env":{"X_ENVIRONMENT_VARIABLE":"desiredvalue"}}, (error,stream) => {....
for it to work correctly

@rgillan rgillan closed this as completed Oct 24, 2023
@alanhe421
Copy link

image

echo $X_LOGIN_IP not works.

@mscdex
Copy link
Owner

mscdex commented Aug 20, 2024

@alanhe421 The server may be restricting what environment variables you can send. For OpenSSH servers, this is controlled by their AcceptEnv config option which by default allows nothing at all for security reasons.

@alanhe421
Copy link

@alanhe421 The server may be restricting what environment variables you can send. For OpenSSH servers, this is controlled by their AcceptEnv config option which by default allows nothing at all for security reasons.

Thank you very much. I just checked and confirmed that this was indeed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants