Sha256: 75aab393fbb1d330ef2e3ad4565c5818f517beb701325c321fd255e14940036e
Contents?: true
Size: 882 Bytes
Versions: 14
Compression:
Stored size: 882 Bytes
Contents
# frozen_string_literal: true module Groundskeeper # Wraps ssh executable. class Ssh COMMAND = "ssh" DEFAULT_CONNECT_TIMEOUT_IN_S = 5 # ssh arguments CONNECT_WITH_TIMEOUT = "-o ConnectTimeout=#{DEFAULT_CONNECT_TIMEOUT_IN_S}" REMOTE_ECHO = "%<options>s %<username>s@%<domain_name>s \"echo 'groundskeeper'\"" attr_reader :domain_name, :ssh, :username def self.build(username, domain_name) new Executable.new(COMMAND), username, domain_name end def initialize(ssh, username, domain_name) @ssh = ssh @username = username @domain_name = domain_name end def can_connect? ssh.execute(format(REMOTE_ECHO, options: CONNECT_WITH_TIMEOUT, username: username, domain_name: domain_name)).strip == "groundskeeper" end end end
Version data entries
14 entries across 14 versions & 1 rubygems