forked from eagletmt/libssh-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sshkit.rb
executable file
·35 lines (29 loc) · 1.03 KB
/
sshkit.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env ruby
require 'shellwords'
require 'sshkit'
require 'sshkit/backends/libssh'
require 'sshkit/dsl'
SSHKit.config.backend = SSHKit::Backend::Libssh
SSHKit.config.backend.configure do |backend|
backend.pty = ENV.key?('REQUEST_PTY')
backend.ssh_options[:user] = ENV['SSH_USER']
if ENV.key?('SSH_PORT')
backend.ssh_options[:port] = ENV['SSH_PORT'].to_i
end
end
SSHKit.config.output = SSHKit::Formatter::Pretty.new($stdout)
SSHKit.config.output_verbosity = :debug
include SSHKit::DSL # rubocop:disable Style/MixinUsage
on %w[barkhorn rossmann], in: :parallel do |host|
date = capture(:date)
puts "#{host}: #{date}"
end
on %w[barkhorn rossmann], in: :parallel do
execute :ruby, '-e', Shellwords.escape('puts "stdout"; $stderr.puts "stderr"')
execute :false, raise_on_non_zero_exit: false # rubocop:disable Lint/BooleanSymbol
end
on %w[barkhorn rossmann], in: :parallel do |host|
upload! __FILE__, '/tmp/sshkit.rb'
upload! StringIO.new("libssh\n"), '/tmp/libssh.txt'
download! '/etc/passwd', "/tmp/#{host}-passwd"
end