You are not logged in.

#1 2011-10-09 07:19:01

anshumanb
Member
From: New Zealand
Registered: 2011-10-09
Posts: 8

Can't use ssh client as normal user [SOLVED]

Hi
On my laptop, I can't seem to use the ssh client as a normal user.
ssh username@host doesn't work but
sudo ssh username@host works

I've tried ssh'ing into my Webfaction account and ssh localhost. Neither work when I run as a normal user. It seems to sit there instead of asking for the password.  This problem doesn't occur on my PC or at work (and I've got Arch on all 3 big_smile). Unfortunately, Google hasn't proved to be very helpful either in this case.

Running ssh -v anshumanb@anshumanb.webfactional.com gives me:

OpenSSH_5.9p1, OpenSSL 1.0.0e 6 Sep 2011
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to anshumanb.webfactional.com [174.121.79.174] port 22.
debug1: Connection established.
debug1: identity file /home/bhaduri/.ssh/id_rsa type 1
debug1: identity file /home/bhaduri/.ssh/id_rsa-cert type -1
debug1: identity file /home/bhaduri/.ssh/id_dsa type -1
debug1: identity file /home/bhaduri/.ssh/id_dsa-cert type -1
debug1: identity file /home/bhaduri/.ssh/id_ecdsa type -1
debug1: identity file /home/bhaduri/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 04:7d:2e:35:77:cc:a1:1b:15:b2:7f:2b:4e:03:f6:67
debug1: Host 'anshumanb.webfactional.com' is known and matches the RSA host key.
debug1: Found key in /home/bhaduri/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received

before it hangs.
Any idea what might be the problem? Thanks in advance for your help.

Last edited by anshumanb (2011-10-12 10:59:05)

Offline

#2 2011-10-09 11:14:45

splondike
Member
Registered: 2008-10-19
Posts: 16

Re: Can't use ssh client as normal user [SOLVED]

Can you use ssh from a different (non root) user? Also, if you temporarily rename your ~/.ssh folder to remove any customizations you may have, does it work then (with password login)? The permissions you need for the .ssh stuff are pretty specific, make sure it looks like this:

$ ls -l ~/.ssh
-rw-r--r-- 1 normal users   463 Aug 21 00:52 config
-rw------- 1 normal users  1766 Aug 21 00:52 id_rsa
-rw-r--r-- 1 normal users   395 Aug 21 00:52 id_rsa.pub
-rw-r--r-- 1 normal users 10867 Sep 17 13:19 known_hosts

Offline

#3 2011-10-10 09:55:03

anshumanb
Member
From: New Zealand
Registered: 2011-10-09
Posts: 8

Re: Can't use ssh client as normal user [SOLVED]

Tried creating a new user and ssh'ing; and renaming the .ssh folder with no luck. Also I noticed that
su root
ssh username@host
doesn't work (even though it should since I'm the root user)
but
sudo ssh username@host does.

I'm stumped as to what could be wrong here.

Offline

#4 2011-10-11 11:07:41

splondike
Member
Registered: 2008-10-19
Posts: 16

Re: Can't use ssh client as normal user [SOLVED]

It seems like it could be an environment variable difference. su, su -, and sudo all operate differently. su keeps the environment from the current shell (e.g. the working directory and PATH). su - <user> replaces the current environment with <user>'s (a guy at work exclusively uses this version for this reason). sudo seems to include the fewest variables, for example /etc/profile and /etc/profile.d/* don't seem to be loaded.

Try su - root and see if that works. In any case, use the env command to work out the difference between the working and non-working environments. Perhaps you're using an ssh agent which is hanging when SSH asks for the key password, or maybe your path is pointing to an ssh you're not expecting?

Offline

#5 2011-10-12 10:56:55

anshumanb
Member
From: New Zealand
Registered: 2011-10-09
Posts: 8

Re: Can't use ssh client as normal user [SOLVED]

Aha

splondike wrote:

It seems like it could be an environment variable difference.

It does indeed seem to be an environment variable at play. su - root then ssh works fine. After comparing the environment variables, turns out that unsetting SSH_AUTH_SOCK fixes this issue. I'm not sure how it gets set in the first place, but for now I'm rolling with an unset SSH_AUTH_SOCK in my bashrc till I figure it out. Thanks a lot for your help.

PS: SSH_AUTH_SOCK was set to /tmp/gpg-GkyCLU/S.gpg-agent.ssh previously

Offline

#6 2011-10-15 02:34:22

splondike
Member
Registered: 2008-10-19
Posts: 16

Re: Can't use ssh client as normal user [SOLVED]

Sounds like you have an ssh agent running (probably gpg-agent). I suspect it's hanging when ssh asks it for the decrypted private key. To check it's gpg-agent, you can look up the process corresponding to the SSH_AGENT_PID environment variable. This wiki page might interest you if you want to work out why it's hanging.

In any case, it's good that you got things working smile.

Offline

Board footer

Powered by FluxBB