first commit

This commit is contained in:
Artem Anufrij
2026-10-07 18:56:27 +02:00
commit 2a8a60b725
7768 changed files with 1550851 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
/**
Check if the process is running in an SSH session.
@example
```
import isInSsh from 'is-in-ssh';
if (isInSsh) {
console.log('Running in an SSH session');
}
```
*/
declare const isInSsh: boolean;
export default isInSsh;
+7
View File
@@ -0,0 +1,7 @@
import process from 'node:process';
const isInSsh = Boolean(process.env.SSH_CONNECTION
|| process.env.SSH_CLIENT
|| process.env.SSH_TTY);
export default isInSsh;
+9
View File
@@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+43
View File
@@ -0,0 +1,43 @@
{
"name": "is-in-ssh",
"version": "1.0.0",
"description": "Check if the process is running in an SSH session",
"license": "MIT",
"repository": "sindresorhus/is-in-ssh",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"sideEffects": false,
"engines": {
"node": ">=20"
},
"scripts": {
"test": "xo && node --test"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"ssh",
"detect",
"detection",
"session",
"remote",
"connection",
"environment",
"check",
"is"
],
"devDependencies": {
"xo": "^1.2.3"
}
}
+43
View File
@@ -0,0 +1,43 @@
# 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
```sh
npm install is-in-ssh
```
## Usage
```js
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`)
## Related
- [is-wsl](https://github.com/sindresorhus/is-wsl) - Check if the process is running inside Windows Subsystem for Linux
- [is-docker](https://github.com/sindresorhus/is-docker) - Check if the process is running inside a Docker container
- [is-inside-container](https://github.com/sindresorhus/is-inside-container) - Check if the process is running inside a container