Installation Guide
This guide will walk you through installing Net::SSH and its dependencies.
System Requirements
- Ruby: Net::SSH requires Ruby version 2.6 or newer. You can check your Ruby version with
ruby -v
. -
OpenSSL: You need Ruby's OpenSSL bindings with a version of OpenSSL greater than
1.0.1
. Most modern Ruby installations include this. You can verify it by running:ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'
Standard Installation
The simplest way to install Net::SSH is using RubyGems:
gem install net-ssh
You may need to use sudo
depending on your system's configuration.
Using Bundler
For managing dependencies in a project, it's recommended to use Bundler. Add Net::SSH to your Gemfile
:
source 'https://rubygems.org'
gem 'net-ssh'
Then, run bundle install
.
Verifying the Gem Signature
For enhanced security, all Net::SSH gem releases are cryptographically signed. To verify the gem's integrity upon installation, follow these steps:
-
Add the public key as a trusted certificate. You only need to do this once.
# Download the public certificate curl -O https://raw.githubusercontent.com/net-ssh/net-ssh/master/net-ssh-public_cert.pem # Add it to RubyGems' trusted certificates gem cert --add net-ssh-public_cert.pem
-
Install the gem with high security.
gem install net-ssh -P HighSecurity
If the signature is valid, the gem will install. If not, RubyGems will raise an error, protecting you from potentially tampered code.
Optional Dependencies for Extra Features
Net::SSH uses optional gems to enable certain modern cryptographic algorithms. If you need support for these features, you must add the corresponding gems to your project's Gemfile
.
-
ED25519 and Curve25519 Support:
For
ssh-ed25519
keys and thecurve25519-sha256
key exchange algorithm, add the following gems:gem 'ed25519', '~> 1.2' gem 'x25519' gem 'bcrypt_pbkdf', '~> 1.0' # Not required for JRuby
-
ChaCha20-Poly1305 Cipher Support:
To use the
chacha20-poly1305@opnessh.com
cipher, which offers high performance, add therbnacl
gem:gem 'rbnacl', '~> 7.1'
-
Ruby 3.0+ WebRick dependency:
If you are using Ruby 3.0 or greater, you might need to add
webrick
if it's not already part of your dependencies, as it was removed from the standard library.gem 'webrick'
Example Gemfile with All Features
source 'https://rubygems.org'
gem 'net-ssh'
# For ED25519 and Curve25519 support
gem 'ed25519', '~> 1.2'
# JRuby does not support bcrypt_pbkdf
gem 'bcrypt_pbkdf', '~> 1.0', platforms: [:mri, :mingw]
gem 'x25519', platforms: [:mri, :mingw]
# For ChaCha20-Poly1305 cipher support
gem 'rbnacl', '~> 7.1'
# Required for some development/test tasks in Ruby 3.0+
gem 'webrick', require: false if RUBY_VERSION.to_i >= 3