0

I'm trying to set up ssh-add/ssh-askpass so that it asks me for my ssh key passwords when I first login to my desktop environment.

I've added a .xsession file to my home directory which contains the following:

ssh-add ~/.ssh/my_key

Right after I first login using my username/password a dialog pops up asking me to enter the password for the key I specified; however, after I enter the password, I'm always returned back to the login screen and I can't login.

I had this same problem before and I solved it somehow, unfortunately, I didn't take any notes on what I did and I also can't seem to find the solution online anywhere. Any ideas? I'm using Debian 8 with LXDE and lightdm.

  • Please provide the entire .xsession file, at least, and say what your DM is. You can edit your post to add more information. – Michael Homer Sep 11 '16 at 6:55
  • 1
    You may also find pam_ssh more convenient (depending on your security requirements). – Michael Homer Sep 11 '16 at 6:56
  • @MichaelHomer updated to include the .xsession file contents and display manager. – zhdason Sep 17 '16 at 19:14
1

The .xsession script runs your entire session. When the script stops running, that's the end, and you're logged back out. If it only contains one command, that's the whole session.

It should at least start your window manager:

exec startlxde

You may want to run several background commands and then the single exec line, which "becomes" the session at that point. Nothing after that line will run.


I imagine that LXDE has some sort of autostart functionality you could use instead of .xsession. pam_ssh is made for exactly what you're doing, as well.

  • Thanks, I didn't realize that you're logged out once the .xsession script is complete. It was your comment about the autostart functionality that lead me to my final solution. I feel like the method I used the first time I got this working involved placing a .desktop file in ~/.config/autostart; I tried this approach again, but, after logging in and entered my password using the GUI prompt, the key was still not available in ssh-agent, not sure why. My final working solution was to place @ssh-add /path/to/.ssh/key_file in ~/.config/lxsession/LXDE/autostart. – zhdason Sep 18 '16 at 20:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.