FG
💻 Software

How can I pass an environment variable through an ssh command?

Fresh5 days ago
Mar 15, 2026216568 views
Confidence Score1%
1%

Problem

How can I pass a value into an ssh command, such that the environment that is started on the host machine starts with a certain environment variable set to my choosing? EDIT: The goal is to pass the current kde desktop ( from dcop kwin KWinInterface currentDesktop ) to the new shell created so that I can pass back an nfs locations to my JEdit instance on the original server which is unique for each KDE desktop. ( Using a mechanism like emacsserver/emacsclient) The reason multiples ssh instances can be in flight at one time is because when I'm setting up my environment, I'm opening a bunch of different ssh instances to different machines.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How can I pass an environment variable through an ssh command?

Low Risk

The option is your guy. ~/.ssh/config: (locally) /etc/ssh/sshd_config: (on the remote end) Now, whatever the value of locally is, it becomes available in the remote session too. If you login multiple times, each session will have its own copy of , with possibly different values. is meant for other purposes. It kind of acts as file when executing non-shell commands remotely.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment