Class: Bosh::Cli::SSHSession
Constant Summary collapse
- SSH_USER_PREFIX =
'bosh_'
Instance Attribute Summary collapse
-
#public_key ⇒ Object
readonly
Returns the value of attribute public_key.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#initialize ⇒ SSHSession
constructor
A new instance of SSHSession.
- #set_host_session(session) ⇒ Object
- #ssh_known_host_option(port) ⇒ Object
- #ssh_known_host_path(port) ⇒ Object
- #ssh_private_key_option ⇒ Object
- #ssh_private_key_path ⇒ Object
Constructor Details
#initialize ⇒ SSHSession
Returns a new instance of SSHSession.
10 11 12 13 14 |
# File 'lib/cli/ssh_session.rb', line 10 def initialize @session_uuid = SecureRandom::uuid @public_key = generate_rsa_key @user = random_ssh_username end |
Instance Attribute Details
#public_key ⇒ Object (readonly)
Returns the value of attribute public_key.
8 9 10 |
# File 'lib/cli/ssh_session.rb', line 8 def public_key @public_key end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
8 9 10 |
# File 'lib/cli/ssh_session.rb', line 8 def user @user end |
Instance Method Details
#cleanup ⇒ Object
40 41 42 43 |
# File 'lib/cli/ssh_session.rb', line 40 def cleanup remove_private_key remove_known_host_file end |
#set_host_session(session) ⇒ Object
16 17 18 |
# File 'lib/cli/ssh_session.rb', line 16 def set_host_session(session) @host_session = session end |
#ssh_known_host_option(port) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/cli/ssh_session.rb', line 20 def ssh_known_host_option(port) path = user_known_host_path(port) if path.length > 0 path = "-o UserKnownHostsFile=#{path}" end return path end |
#ssh_known_host_path(port) ⇒ Object
28 29 30 |
# File 'lib/cli/ssh_session.rb', line 28 def ssh_known_host_path(port) user_known_host_path(port) end |
#ssh_private_key_option ⇒ Object
32 33 34 |
# File 'lib/cli/ssh_session.rb', line 32 def ssh_private_key_option "-i#{ssh_private_key_path}" end |
#ssh_private_key_path ⇒ Object
36 37 38 |
# File 'lib/cli/ssh_session.rb', line 36 def ssh_private_key_path File.join(ENV['HOME'], '.bosh', 'tmp', "#{@session_uuid}_key") end |