Skip to content

Instantly share code, notes, and snippets.

@sumskyi
Created February 25, 2010 10:38
Show Gist options
  • Save sumskyi/314447 to your computer and use it in GitHub Desktop.
Save sumskyi/314447 to your computer and use it in GitHub Desktop.
ssh keys switching
#!/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