# keychain and X [SOLVED]

## nichocouk

Hello all,

I've installed keychain and I'm running it happily except for one thing. I followed the guide and put my keychain instruction in my .bash_profile .

It works fine when I boot, log in with a console and then startx , but if does not work properly if I have xdm in the default runlevel for X to start automatically. In this case I am not prompted for my passphrase and have to enter my passwords .

Can anyone help me please?

Cheers,

----------

## Deepak420

You should try and make the changes to .bashrc

----------

## nichocouk

I don't think this would make any difference as .bashrc is sourced by .bash_profile.

----------

## Deepak420

The problem is that (as I recall) bash_profile does not get parsed when logging in using xdm. You could instead try using .xsession, though I don't know if this works with xdm (as I don't use xdm) but it would probably be a better approach. Anyways, it never hurts to try  :Wink: 

----------

## gour

 *nichocouk wrote:*   

> I don't think this would make any difference as .bashrc is sourced by .bash_profile.

 

What would be the proper way to have keychain working in KDE/GNOME   :Question: 

Sincerely,

Gour 

----------

## nichocouk

Hey,

I've tried to put the following lines in my ~/.xsession:

```

/usr/bin/keychain --quiet ~/.ssh/id_dsa

[[ -f $HOME/.keychain/$HOSTNAME-sh ]] && . $HOME/.keychain/$HOSTNAME-sh

```

But, it does not work. I don't get any error message, but I don't get any prompt for my passphrase either.

Also, I've checked and it should not be placed in .bashrc as this file should not generate any output (or it will break the scp command) and despite the --quiet option in my keychain invocation, I still have warning messages that can be printed.

Thanks anyway for these suggestions. 

Any other idea?

----------

## Deepak420

No definative answer, but x11-ssh-askpass should provide a place to start. I may set up xdm to try and crack this nut.

----------

## nichocouk

Cool! It looks promising! I've emerged it but I will need to wait I'm back home to try it. I'll let you know asap.

Thanks for your help!

 :Cool: 

----------

## nichocouk

mmm, well I've tried this morning, but again I did not get a prompt for my passphrase when XDM/GDM started. I will have to see if something needs to be done for ssh-askpass to work. I've seen on other threads (e.g. here) that there might be a small problem to fix. 

I'll let you know!

[EDIT] I might try first to install the 'unstable' version x11-ssh-askpass-1.2.4.1-r1 since it seems to fix a problem that exists with the stable x11-ssh-askpass-1.2.2-r1

----------

## nichocouk

Yep!

Just to say that I got it working after setting the SSH_ASKPASS environment variable in my .bash_profile. So my .bash_profile looks like this:

```

export SSH_ASKPASS='/usr/bin/x11-ssh-askpass'

/usr/bin/keychain --quiet ~/.ssh/id_dsa

[[ -f $HOME/.keychain/$HOSTNAME-sh ]] && . $HOME/.keychain/$HOSTNAME-sh

```

and I get a X prompt for my passphrase when I login with gdm.

Cool!    :Smile: 

Thanks for your help Deepak420.

----------

## gour

 *nichocouk wrote:*   

> Yep!
> 
> and I get a X prompt for my passphrase when I login with gdm.
> 
> Cool!   
> ...

 

Thank you. It is very nice solution   :Cool: 

Sincerely,

Gour

----------

## masseya

Not sure if this will still be useful to anyone here, but I thought I would post a link to how I handle keychain in case it would help anyone here.

----------

## _puck_

Could someone please add this solution to the official keychain howto. I had found this once and after a reinstall I searched for a very long time, to find this hint again.

----------

