Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I cannot ssh anything I was able to. After a little digging I found out that it's not reading ssh config from my home directory.

$ ssh -xvvv server
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
(...)

When on an identical computer of a friend, where everything works it looks like this:

$ ssh -xvvv server
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/kuba/.ssh/config
(...)

It worked earlier and I am not aware of anything I could have done to cause this problem. How could this happen, and how to fix it?

In documentation link pointed by tike it states that

Because of the potential for abuse, this file must have strict permissions: read/write for the user, and not accessible by others.

My permissions are:

$ ls -la ~/.ssh
total 80
drwx------+ 42 kuba  1029   1428 Jul  1 16:33 ..
-rwx------   1 kuba  1029   1528 May 15 13:07 config
(...)

I think the problem might be with a confusion about home directory. When I force the local config file it starts to work, and then suddenly starts reading from /nas/kuba

$ ssh -xvvvF ~/.ssh/config server
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/kuba/.ssh/config
debug1: /Users/kuba/.ssh/config line 1: Applying options for *
debug1: /Users/kuba/.ssh/config line 39: Applying options for bio
debug2: ssh_connect: needpriv 0
debug1: Connecting to XXXX [YYYY.YYY.YYY.YYY] port 22.
debug1: Connection established.
debug1: identity file /nas/kuba/.ssh/id_dsa type -1
                      ^^^^^^^^^^

But my home dir seems to be set ok:

$ cd ~; pwd
/Users/kuba
$ echo $HOME
/Users/kuba
share|improve this question
1  
I was able to workaround a problem. I copied contents of ~/.ssh to /nas/kuba/.ssh. So it's actually problem with ssh suddenly using the wrong home directory, which is probably not really an ssh problem. –  Kuba Jul 1 '14 at 15:28
    
That last comment would be very useful information to edit into the question. –  David Z Jul 1 '14 at 19:51
    
Your output indicates you are using DSA. I would find a way to switch to RSA, as it is the best/newest & I believe DSA is broken. –  trysis Jul 2 '14 at 0:09
    
@trysis As far as I know, DSA is not exactly broken. However DSA is extremely sensitive to the quality of your PRNG. RSA is more robust in that respect. So I too avoid DSA keys. –  kasperd Aug 8 '14 at 16:43
    
@Kuba As far as I can tell ssh ignores the HOME environment variable. It is bad practice to ignore HOME, it seems that is what ssh does. If it does not use HOME, the only alternative I am aware of is to look it up from the uid. If you have two entries in /etc/passwd with identical uid, then both would end up using the same .ssh/config file even if they had different home. –  kasperd Aug 8 '14 at 16:52

2 Answers 2

You seem to be trapped between user specific vs global ssh_config.

Please check the permission settings of your user's configuration file (~/.ssh/config) and your system-wide configuration file (/etc/ssh/ssh_config) to understand in more details.

You can read more about this here. Practically, all files under your user based .ssh directory should be on 600, and the config file should be on 644. You can set this with the following commands in your home directory:

chmod 600 ~/.ssh/* 
chmod 644 ~/.ssh/config
share|improve this answer
    
So I understand from the doc that it first should read config from my home directory, and later from the global (/etc/ssh/ssh_config) The question is - why is it ommitting my local config? –  Kuba Jul 1 '14 at 15:07
    
updated answer above –  tike Jul 1 '14 at 15:18
    
I tried. Nothing changed. I updated my quetsion with more details. –  Kuba Jul 1 '14 at 15:22
    
if you havent changed above question drastically while editing: debug1: /Users/kuba/.ssh/config line 1: Applying options for * debug1: /Users/kuba/.ssh/config line 39: Applying options for bio its reading config, and your configuration wildcard seem to be playing role. I would keep simple config file to test first with defined port and dest server. –  tike Jul 1 '14 at 15:31
    
Actually I changed the question drastically to the point that I should probably close it. It seems that ssh is treating other directory as my home folder. Something that's neither ~, nor $HOME. –  Kuba Jul 1 '14 at 15:34

check permissions

ls -lsd ~/.ssh

and

ls -ls ~/.ssh/*

If the permissions are bad then the ssh client won't try to read from it

share|improve this answer
    
0 drwx------ 9 kuba /Users/kuba/.ssh 8 -rwx------ 1 kuba /Users/kuba/.ssh/config looks like I am the owner of all of them –  Kuba Jul 1 '14 at 15:02
    
@Kuba try with ls -la ~/.ssh/ –  c4f4t0r Jul 1 '14 at 15:04
    
ls -la ~/.ssh total 80 drwx------ 9 kuba 1029 306 Jul 1 16:33 . drwx------+ 42 kuba 1029 1428 Jul 1 16:33 .. -rw-r--r-- 1 kuba 1029 406 May 7 14:53 authorized_keys -rwx------ 1 kuba 1029 1528 May 15 13:07 config -rwx------ 1 kuba 1029 1675 May 7 14:53 id_rsa -rwx------ 1 kuba 1029 406 May 7 14:53 id_rsa.pub -rw-r--r-- 1 kuba 1029 16049 May 22 09:36 known_hosts –  Kuba Jul 1 '14 at 15:05
    
@are you sure, you home user dir isn't to open? –  c4f4t0r Jul 1 '14 at 15:13
1  
That + over there... isn't that ACLs? That might be the culprit? –  Jorge Suárez de Lis Jul 1 '14 at 15:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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