#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require 'net/ssh/cli' require 'irb' begin $NET_SSH = Net::SSH.start("localhost") $CLI = Net::SSH::CLI::Session.new(net_ssh: $NET_SSH, default_prompt: "@") $CLI.open_channel puts "assuming your prompt contains '@'" puts $CLI.cmd "echo 'hello world'" rescue StandardError => error puts "#{error.class} #{error.message}" puts error.backtrace ensure puts "" puts File.read(__FILE__).lines.map {|line| "[bin/localhost] " + line} puts "" IRB.start(__FILE__) end ## Try one of those # $CLI.cmd "echo 'hello world'" # $CLI.detect_prompt # $CLI.default_prompt # $CLI.cmd "cat /etc/passwd" # $CLI.write "cat /etc/passwd" # $CLI.read # $CLI.cmd "echo 'hello world'"