I have a strange issue where SSH won't properly connect with a private-key if the key file is in certain directories. I've setup the keys on a set of servers and the following command
ssh -i /root/privatekey
[email protected]
works fine and I login to the given host without getting prompted by a password, but this command:
ssh -i /etc/keyfiles/privatekey
[email protected]
gives me a password prompt. I've narrowed it down that this behavior occurs in only some sub-directories of /etc/. For example /etc/httpd1/ gives me a password prompt but /etc/httpd/ does not.
What I've checked so far:
All private key files used are identical (copied from the original file).
The private key file and directories used have identical permissions.
No relevant error messages in the server/client logs.
No interesting debug messages from ssh -v (it just seems to skip the key file).
It happens with connecting to different hosts.
After more testing it is not the actual directory name. For example:
mkdir /etc/test
cp /root/privatekey /etc/test
ssh -i /etc/test/privatekey
[email protected] # Results in password prompt
cp /root/privatekey /etc/httpd # Existing directory
ls -ald
test httpd
# drwxr-xr-x 4 root root 4096 Mar 5 18:25 httpd
# drwxr-xr-x 2 root root 4096 Mar 5 18:43
test
ssh -i /etc/httpd/privatekey
[email protected] # Results in *no* prompt
rm -r
test
cp -R /etc/httpd /etc/test
ssh -i /etc/test/privatekey
[email protected] # Results in *no* prompt`
I'm sure its just something simple I've overlooked but I'm at a loss.