class Caco::Ssh::AuthorizedKeysAdd
Public Instance Methods
add_key(ctx, key:, identifier:, output:, **)
click to toggle source
# File lib/caco/ssh/authorized_keys_add.rb, line 43 def add_key(ctx, key:, identifier:, output:, **) output << "#{key} #{identifier}\n" ctx[:created] = true ctx[:content] = output end
change_key(ctx, key:, identifier:, output:, **)
click to toggle source
# File lib/caco/ssh/authorized_keys_add.rb, line 37 def change_key(ctx, key:, identifier:, output:, **) output.gsub!(/^.*#{identifier}$/, "#{key} #{identifier}") ctx[:content] = output end
check_user_ssh_folder(ctx, user:, user_home:, **)
click to toggle source
# File lib/caco/ssh/authorized_keys_add.rb, line 59 def check_user_ssh_folder(ctx, user:, user_home:, **) ctx[:ssh_home] = ssh_home = "#{Caco.config.write_files_root}#{user_home}/.ssh" FileUtils.mkdir_p(ssh_home) File.chmod(0700, ssh_home) FileUtils.chown user, nil, ssh_home rescue Errno::EPERM true end