Created
February 25, 2010 10:38
-
-
Save sumskyi/314447 to your computer and use it in GitHub Desktop.
ssh keys switching
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
#!/usr/bin/env ruby | |
require 'pp' | |
logins = %w(vlad marat artyom) | |
change_to = ARGV.first | |
raise 'Enter name as param!' if change_to.nil? | |
change_to.strip! | |
raise "Allowed logins are: [#{logins.join(', ')}]" unless logins.include? change_to | |
ssh_dir = '~/.ssh/' | |
keys = %w(id_rsa id_rsa.pub) | |
keys.each do |k| | |
`rm -f #{ssh_dir}#{k} ` | |
`ln -s #{ssh_dir}#{change_to}_#{k} #{ssh_dir}#{k}` | |
`chmod 600 #{ssh_dir}#{k}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment