class RediPress::SSHKeys
This class contains stuff related to SSH Keys
Public Class Methods
load_ssh_keys()
click to toggle source
Load all SSH Keys stored in the user’s SSH directory
Example:
>> RediPress::SSHKeys.load_ssh_keys => nil
# File lib/redipress/ssh.rb, line 15 def self.load_ssh_keys # Get the path to the user's personal SSH directory ssh_directory = File.join(Dir.home, ".ssh") # Return unless the SSH directory exists return nil unless File.directory?(ssh_directory) # Get the paths of all SSH Keys ssh_keys = Dir.glob(File.join(Dir.home, ".ssh", "*.pub")).map do |key| File.join(File.dirname(key), File.basename(key, ".pub")) end # Adjust the configuration options for SSH Kit SSHKit::Backend::Netssh.configure do |ssh| # Set the SSH options ssh.ssh_options = { # Set the SSH Keys to use when attempting to login to the remote host keys: ssh_keys, # Set the authentication methods auth_methods: %w(publickey) } end nil end