New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

is-in-ssh

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-in-ssh

Check if the process is running in an SSH session

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
5.6M
8.73%
Maintainers
1
Weekly downloads
 
Created
Source

is-in-ssh

Check if the process is running in an SSH session

Useful for determining if your Node.js process is being executed over SSH, which can affect how you handle operations like opening files, browsers, or using system-specific commands.

Install

npm install is-in-ssh

Usage

import isInSsh from 'is-in-ssh';

if (isInSsh) {
	console.log('Running in an SSH session');
}

How it works

The package detects SSH sessions by checking for the presence of standard SSH environment variables:

  • SSH_CONNECTION
  • SSH_CLIENT
  • SSH_TTY

These variables are automatically set by SSH servers when establishing a connection.

Limitations

  • The detection relies on environment variables, which could theoretically be spoofed or cleared
  • May return true for ssh localhost connections (which are technically SSH sessions)
  • Environment variables might not be inherited by all child processes or after privilege escalation (e.g., sudo)
  • is-wsl - Check if the process is running inside Windows Subsystem for Linux
  • is-docker - Check if the process is running inside a Docker container
  • is-inside-container - Check if the process is running inside a container

Keywords

ssh

FAQs

Package last updated on 12 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts