Last active
September 2, 2018 16:43
-
-
Save ipepe/e587fc1f98e1c0cb049a185fe86715b9 to your computer and use it in GitHub Desktop.
Add my id_rsa.pub to authorized_keys in Capistrano
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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