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(host: 'server.example.com', user: 'deploy', keys: ['~/.ssh/id_ed25519'])
result = client.run(command: 'uptime')- Ruby >= 3.4
- LegionIO framework
- SSH server access
net-ssh>= 7.0ed25519— Ed25519 key supportbcrypt_pbkdf— OpenSSH private key format support
- Added standalone
Clientclass. - Fixed
opts.key?(:timeout)inHelpers::Connection— the previousopts.key(:timeout)always returned a truthy key object, so thetimeoutoption was never read from task kwargs.
MIT