Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @key_path; remove blank lines with white space #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ In your Capfile, require the gem:

And in your deploy stage, after you register servers and services, create the one time keys:

server ENV['HOST'], user: ENV['USER'], roles: %w{app}
Capistrano::OneTimeKey.generate_one_time_key!
# Optional modification of ssh options.
ssh_opts = fetch(:ssh_options)
ssh_opts[:forward_agent] = true
ssh_opts[:verbose] = false

## Contributing

Expand Down
4 changes: 2 additions & 2 deletions lib/capistrano/one_time_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def self.tmpdir
end

def self.temporary_ssh_private_key_path
File.join(tmpdir, "capistrano_key")
@key_path ||= File.join(tmpdir, "capistrano_key")
end

def self.comment
Expand Down Expand Up @@ -50,7 +50,7 @@ def self.add_key_to_host capistrano_host, public_key
end

def self.remove_key_from_host capistrano_host, public_key
execute_on_remote capistrano_host, "sed -i.bak -e '/#{comment}$/d' -e '/^$/d' ~/.ssh/authorized_keys && rm ~/.ssh/authorized_keys.bak"
execute_on_remote capistrano_host, "sed -i.bak -e '/#{comment}$/d' -e '/^\s*$/d' ~/.ssh/authorized_keys && rm ~/.ssh/authorized_keys.bak"
end

def self.execute_on_remote capistrano_host, command
Expand Down