SSH remote command execution for LegionIO. Run commands on remote servers and trigger reboot or shutdown via Net::SSH from within task chains.
gem install lex-sshOr add to your Gemfile:
gem 'lex-ssh'| Method | Parameters | Description |
|---|---|---|
run |
command:, server:, user: (default: 'root') |
Execute a single command via SSH |
run_multiple |
commands:, server:, user: (default: 'root') |
Execute multiple commands sequentially |
Returns { success:, results:, server: } per command.
| Method | Parameters | Description |
|---|---|---|
reboot |
server:, user: (default: 'root'), delay: (default: 0) |
Reboot the server via shutdown -r |
shutdown |
server:, user: (default: 'root'), delay: (default: 0) |
Halt the server via shutdown -h |
delay is the number of minutes to wait (0 = immediate).
Pass authentication kwargs alongside other parameters:
| Parameter | Description |
|---|---|
password |
Password authentication |
key_data |
Inline key data |
keys |
Array of key file paths |
passphrase |
Key passphrase |
timeout |
Connection timeout in seconds (default: 5) |
Use Legion::Extensions::Ssh::Client outside the full LegionIO framework.
require 'legion/extensions/ssh'
client = Legion::Extensions::Ssh::Client.new(server: 'server.example.com', user: 'deploy', keys: ['~/.ssh/id_ed25519'])
result = client.run(command: 'uptime')Constructor: Client.new(server:, user: 'root', **extra). Additional kwargs (keys:, password:, timeout:, etc.) are stored and passed through to Net::SSH on each call.
- Ruby >= 3.4
- SSH server access
net-ssh>= 7.0ed25519— Ed25519 key supportbcrypt_pbkdf— OpenSSH private key format support
MIT