Are you running xterm from inside your Gnome session as well?
Try this in Gnome Terminal:
echo $SSH_AUTH_SOCK
Then try the same in xterm.
It should print something like
/tmp/keyring-abc123/ssh
in both.
I'm guessing it doesn't print something like that in xterm.
If it's empty, something is clearing it (or not setting it).
If looks more like
/tmp/ssh-defgh67890/agent
then you are also running ssh-agent somewhere, which will get confusing.
Here's what I'd try:
Run echo $0
in both. Does one have -
at the start and the other not?
If so, you are probably running ssh-agent in login shells, but not non-login shells. Have a look in your ~/.bashrc
or ~/.bash_profile
or equivalent scripts and fix the problem.
Or change whether xterm is started as a login shell:
- using
xterm*loginShell: true
or xterm*loginShell: false
in your ~/.Xdefaults
or ~/.xresources
?
- by running
xterm -ls
or xterm
(without -ls
)
Copy the setting you have for Gnome Terminal under Profile Preferences->Title and Command->Run command as a login shell.
If that fails, try adding echo
statements in your startup files. You'll need to redirect the output to a log file using echo $SSH_AUTH_SOCK >> ~/ssh-debug.log
or similar.
Then log out and back in, and have a look at your ~/ssh-debug.log
.
Then run Gnome Terminal and look at it again.
Then run xterm and look and look at it again.
Look for differences.
Have a look at /etc/pam.d/gdm and System->Preferences->Startup Applications. Do you have any other ssh-agent configuration anywhere in /etc/pam.d?
Have a look /etc/X11/Xsession
and the scripts that it calls.