Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
keychain tip/scriptlet
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
nianderson
Guru
Guru


Joined: 06 May 2003
Posts: 369
Location: Lawrence, KS

PostPosted: Wed May 03, 2006 10:03 pm    Post subject: keychain tip/scriptlet Reply with quote

Ok I have multiple keys that I use for different boxen for ssh access. Sometimes they change or I will add a new one for a different purpose. I name all of my keys something like hostname.id_dsa or rsa. Here is a little keychain wrapper that will load all of the keys in your home directory.
ok ok .... more information

SSH keys are very useful for authentication. You can have 2 form auth with passworded keys, the thing you know (your password), and the thing you have (the ssh key). Or you can have passwordless ssh access (not reccomended).
Please see http://www.gentoo.org/doc/en/keychain-guide.xml for information on howto setup keychain and ssh keys. This script is just a little tool if you have multiple ssh keys that you need to use regurarly.

Say you have a key for work work.id_dsa and a key for your own personal server personal.id_dsa and maybe a key for some clients machine client1.id_dsa all of these are located in your ~/.ssh directory. Now with the normal keychain guide you get the default generated key loaded "id_dsa" but If you generate keys freqently its a pain to go and add each key to the line in your .bash_profile. This script looks in ~/.ssh and automattically loads each key ending with id_dsa or id_rsa into ssh-agent. So it wont try to load every file in there and it ignores your id_dsa.pub and id_rsa.pub keys (public keys explained in the keychain guide) All you have to do when you want to add a new key for a new host is run ssh-keygen and save your new keyfile for your new host. Either source your .bash_profile or logout and log back in and it will load up the new key.


replace keychain ~/.ssh/id_dsa with keychainwrapper (optionally replace it with
Code:
ls $HOME/.ssh/ | grep id_[rd]sa$ | xargs keychain
)
Code:

[[ -f ~/.bashrc ]] && . ~/.bashrc
keychainwrapper
. ~/.keychain/$HOSTNAME-sh


and add keychainwrapper to /usr/local/bin and chmod +x (as root)
Code:

#!/bin/bash
#Keychain wrapper to load multiple keys in ($HOME)
#Automattically loads all keys in ($HOME) ending in id_{rsa,dsa}
ls $HOME/.ssh/ | grep id_[rd]sa$ | xargs keychain


edited to add more indepth explination


Last edited by nianderson on Wed May 03, 2006 11:51 pm; edited 1 time in total
Back to top
View user's profile Send private message
beatryder
Veteran
Veteran


Joined: 08 Apr 2005
Posts: 1138

PostPosted: Wed May 03, 2006 10:10 pm    Post subject: Reply with quote

Could you expand on this a little more? Perhaps explaining how to make theses keys, and how you would use this wrapper? As of right now I don't see how this is useful for anything.
_________________
Dont make it idiot proof, make it work.
Neucode.org
<suppressed key>
Back to top
View user's profile Send private message
nianderson
Guru
Guru


Joined: 06 May 2003
Posts: 369
Location: Lawrence, KS

PostPosted: Wed May 03, 2006 11:52 pm    Post subject: Reply with quote

added some more explination
Back to top
View user's profile Send private message
beatryder
Veteran
Veteran


Joined: 08 Apr 2005
Posts: 1138

PostPosted: Thu May 04, 2006 12:14 am    Post subject: Reply with quote

much better thank you
_________________
Dont make it idiot proof, make it work.
Neucode.org
<suppressed key>
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum