Skip to content

Instantly share code, notes, and snippets.

@ipepe
Last active Sep 2, 2018
Embed
What would you like to do?
Add my id_rsa.pub to authorized_keys in Capistrano
task :add_my_key_to_authorized_keys do
unless `cat "$HOME/.ssh/id_rsa.pub"`.empty?
id_rsa_pub_path = `echo "$HOME/.ssh/id_rsa.pub"`.strip
on roles(:all) do
upload! id_rsa_pub_path, "/tmp/id_rsa.pub"
execute 'cat /tmp/id_rsa.pub .ssh/authorized_keys | sort -u -o .ssh/authorized_keys'
execute 'cat .ssh/authorized_keys'
end
end
end
before :starting, :add_my_key_to_authorized_keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment