explaingit

mitchellh/net-ssh-shell

Analysis updated 2026-07-03 · repo last pushed 2015-03-27

79RubyAudience · developerComplexity · 2/5DormantSetup · easy

TLDR

A Ruby library that keeps a persistent shell session open on a remote server, so commands share state like directory changes and environment variables across multiple executions.

Mindmap

mindmap
  root((repo))
    What it does
      Runs commands remotely
      Keeps shell state
      Supports subshells
    Tech stack
      Ruby
      Net SSH
      RubyGems
    Use cases
      Infrastructure automation
      Deployment scripts
      Config management
    Audience
      Ruby developers
      DevOps engineers
      Automation builders
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Write deployment scripts that change directories and set environment variables across multiple commands on a remote server.

USE CASE 2

Build infrastructure automation tools that need to escalate privileges mid-session using sudo or switch users within a persistent shell.

USE CASE 3

Create configuration management scripts in Ruby that interact with a remote server conversationally rather than running one-off commands.

What is it built with?

RubyNet::SSHRubyGems

How does it compare?

mitchellh/net-ssh-shellmitchellh/virtuosodawarich-app/atlas
Stars793221
LanguageRubyRubyRuby
Last pushed2015-03-272010-12-15
MaintenanceDormantDormant
Setup difficultyeasymoderatehard
Complexity2/52/54/5
Audiencedeveloperdeveloperops devops

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Installs as a standard Ruby gem requiring Net::SSH version 2.

In plain English

Net-ssh-shell is a Ruby library that lets you run commands on a remote server as if you were typing them into the same terminal session. Normally, when you run commands on a remote machine programmatically, each command runs in its own isolated bubble. This library changes that by keeping a single, persistent shell open, so anything you do in one command carries over to the next. The key benefit is statefulness. If you run "cd /usr/local" to change directories and then run "pwd" to see where you are, the second command remembers the directory change from the first. You can also set environment variables in one command and use them in the next. Without this library, you would need to chain everything into a single command or manage complex state tracking yourself. It works as an extension to Net::SSH, a popular Ruby library for connecting to remote servers. You open a connection, start a shell session, and then execute commands one after another within that session. Each command returns an object that includes details like the exit status and the command that was run, so you can check whether things succeeded. The library also supports "subshell" environments, meaning you can switch users or enter a privileged shell like "sudo bash" and continue running commands within that elevated context. This would be useful for anyone building infrastructure automation, deployment scripts, or configuration management tools in Ruby. For example, if you are writing a script that connects to a server, switches to a specific directory, sets some environment variables, and then runs a build command, this library lets you write those steps naturally instead of cramming them into a single line. It is also handy for scenarios where you need to escalate privileges mid-session or interact with shells that expect a ongoing conversation rather than one-off commands. The project is relatively small and focused, doing one thing well rather than trying to be a full automation framework. It requires Net::SSH version 2 and installs as a standard Ruby gem.

Copy-paste prompts

Prompt 1
Help me write a Ruby script using net-ssh-shell that connects to a remote server, changes to /var/www/myapp, sets RAILS_ENV=production, and runs a deploy command, all in the same persistent shell session.
Prompt 2
Show me how to use net-ssh-shell to open a Net::SSH connection, start a subshell with 'sudo bash', and then run multiple commands in that elevated privileged context.
Prompt 3
Write a Ruby deployment script using net-ssh-shell that SSHes into a server, checks the exit status of each command, and stops the deploy if any command fails.

Frequently asked questions

What is net-ssh-shell?

A Ruby library that keeps a persistent shell session open on a remote server, so commands share state like directory changes and environment variables across multiple executions.

What language is net-ssh-shell written in?

Mainly Ruby. The stack also includes Ruby, Net::SSH, RubyGems.

Is net-ssh-shell actively maintained?

Dormant — no commits in 2+ years (last push 2015-03-27).

How hard is net-ssh-shell to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is net-ssh-shell for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub mitchellh on gitmyhub

Verify against the repo before relying on details.