You are not logged in.
I'd like to have a script that will start the ssh agent (and add my key) if it's not running already (run ssh-add automagically for the first time i try to use my key). But let me explain a bit more.
Here's how i login to my server now:
- start KDE [i dont know if it's important or not]
- run a script in konsole: eval ssh-agent; sh-add ~/.ssh/the-key
- type in my password
- now i can ssh to the server like this: ssh serveralias -t screen -RD [i have an alias set in .ssh/config]
The problem with this is that i have to remember to run ssh-add before i try to run ssh.
Here's what i'd like to have:
- run ssh serveralias -t screen -RD
- be asked for the key's password only once in the whole KDE session
So the goal is to run ssh-add automagically for the first time i try to use my key.
Is is possible?
TIA!
Offline
Yes, it's possible. Add this to whatever script you use to start KDE (probably .xinitrc or .xsession):
eval `ssh-agent`
Note the backticks, they're important. Then you should be able to run ssh and it will automatically add the key to the agent the first time you use it.
The important thing is to run ssh-agent before KDE starts. That way the environment variables it sets get propagated to all the processes KDE starts.
Offline
I use keychain (in [extra]) to deal with this for me. Then I have the following in my .zshrc:
if [[ -f ~/.keychain/$HOST-sh ]] && [[ $UID != "0" ]]
then
keychain ~/.ssh/id_dsa
. ~/.keychain/$HOST-sh > /dev/null
fi
So, the first console I get after login, I put in my passphrase, and that's it for the rest of the login.
-nogoma
---
Code Happy, Code Ruby!
http://www.last.fm/user/nogoma/
Offline
Thanks for both replys!
Somehow the xinitrc/xsession way did not work. But keychain did the trick!
Now i use
alias server="keychain ~/.ssh/keyfile -q; ssh host"
Thanks!
Offline
You can use pam_script in /etc/pam.d/kdm to execute commands on login or logout during kde-session authentication.
Offline
You can use pam_script in /etc/pam.d/kdm to execute commands on login or logout during kde-session authentication.
Yup, but my ssh key requires a password and i can't type it this way.
Offline