Skip to content

Set standard SSH environment variables in the workspace #2339

Closed
@mafredri

Description

@mafredri

As a user, I have unified dotfiles that behave differently on different systems and I would like to detect when I'm inside an SSH connection/on a remote system.

We should consider setting the following standard SSH environment variables:

SSH_CLIENT=192.168.0.2 52122 22
SSH_CONNECTION=192.168.0.2 52122 192.168.0.1 22
SSH_TTY=/dev/pts/1

The SSH_TTY is not always /dev/pts/1, it varies depending on how many pseudo ttys have been allocated. It's also not set when running a command without tty (e.g. ssh coder.ws env).

     SSH_CONNECTION        Identifies the client and server ends of the
                           connection.  The variable contains four space-
                           separated values: client IP address, client port
                           number, server IP address, and server port number.
     
     [...]
     
     SSH_TTY               This is set to the name of the tty (path to the
                           device) associated with the current shell or
                           command.  If the current session has no tty, this
                           variable is not set.

Metadata

Metadata

Assignees

Labels

apiArea: HTTP APIcliArea: CLI

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions