Class: SshForever::SecureShellForever

Inherits:
Object
  • Object
show all
Defined in:
lib/cuken/api/ssh-forever.rb

Instance Method Summary collapse

Constructor Details

#initialize(login, options = {}) ⇒ SecureShellForever

Returns a new instance of SecureShellForever.



8
9
10
11
12
13
14
15
16
17
# File 'lib/cuken/api/ssh-forever.rb', line 8

def initialize(, options = {})
  @login   = 
  @options = options
  @username, @hostname = @login.split("@")
  cleanup_ssh_config
  cleanup_identity_files
  local_config_path
  initialization_run
  local_key_path
end

Instance Method Details

#initialization_runObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cuken/api/ssh-forever.rb', line 19

def initialization_run
  unless File.exists?(config_file_path)
    puts "You do not appear to have a config file. Expected one at #{config_file_path}"  unless @options[:quiet]
    existing_ssh_config? ? append_ssh_config : write_ssh_config
    puts "Next: check for a public key."  unless @options[:quiet]
    unless File.exists?(public_key_path)
      puts "You do not appear to have an identity file/public key. Expected one at #{public_key_path}"  unless @options[:quiet]
      confirm_keygen
      generate_public_key
    end
  end
  args = ssh_args()

  copy_public_key(args)

  puts "Success. From now on you can just use plain old 'ssh'. Logging you in..."  unless @options[:quiet]
  status = run_shell_cmd((args))
  #cleanup_ssh_config
  # exitstatus 2 is when ssh-add can't find an agent on local machine.
  # We ought to switch to use Net::SSH libraries....
  exit 1 unless status.exitstatus.to_i == 0 || status.exitstatus.to_i == 2
end

#run_interactiveObject



42
43
44
45
# File 'lib/cuken/api/ssh-forever.rb', line 42

def run_interactive
  system (ssh_args)
  #cleanup_ssh_config
end