Resolved - server drops key recognition

Issues related to applications and software problems
zuser
Posts: 19
Joined: 2013/12/31 16:34:24

Resolved - server drops key recognition

Post by zuser » 2015/05/24 01:19:30

I have CentOS 7 running as a server on home network. The server is used primarily for file storage and an ownCloud service.
Trying to setup ssh keys so I can run rsync without password to do nightly backups from desktop.

Problem is that server fails to accept key recognition after a brief period of time.
I generated keys, setup on client and server and changed permissions as:

Code: Select all

chmod 0744 ~/
chmod 0700 ~/.ssh
chmod 0644 ~/.ssh/authorized_keys

If I immediately return to client, I can ssh to server and/or run scripts to rsync via ssh w/o password but after a few minutes, additional attempts to ssh to server result in request for password.

I can ssh to server with pw, run chmod commands again and will again have access for a few minutes w/o pw request.
Then server refuses to accept keys and cycle starts all over.

/var/log/secure shows this message:
"Authentication refused: bad ownership or modes for directory /home/..."

I have googled and found lots of issues with setting up keys but not this particular one.
Also find several different stated requirements for file permissions but those shown above seem to be most common.

Any help are references to a resolution will be appreciated.
Last edited by zuser on 2015/05/26 21:25:44, edited 1 time in total.

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: server drops key recognition

Post by gerald_clark » 2015/05/24 01:29:35

Why would you have to run chmod again?
Are your permissions changing?
What kind of filesystem are these directories on?
Have you been hacked?

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: server drops key recognition

Post by TrevorH » 2015/05/24 01:45:58

"Authentication refused: bad ownership or modes for directory /home/..."
Is that literally what it says or is "..." some set of characters? Your home directory should be chmod 700, not 744.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

zuser
Posts: 19
Joined: 2013/12/31 16:34:24

Re: server drops key recognition

Post by zuser » 2015/05/24 16:09:12

gerald_clark wrote:Why would you have to run chmod again? That was my question. Only know that after failure to connect, I can ssh w/pw, do "chmod 700" again and client can again connect w/o pw.
Are your permissions changing? "ls -l" shows no changes
What kind of filesystem are these directories on? ext4
Have you been hacked?
I don't think so. I actually have 2 different servers experiencing same issue. Other is an older 32 bit box running CentOS 6.6


Additionally: running an rsync script to backup via ssh seem to "kill" the connection immediately.

As I am not overly familiar using ssh or rsync, am thinking it may be an issue in config or rsync options.
Last edited by zuser on 2015/05/24 16:12:55, edited 1 time in total.

zuser
Posts: 19
Joined: 2013/12/31 16:34:24

Re: server drops key recognition

Post by zuser » 2015/05/24 16:10:57

TrevorH wrote:
"Authentication refused: bad ownership or modes for directory /home/..."
Is that literally what it says or is "..." some set of characters? Your home directory should be chmod 700, not 744.
Yes, copied from the log.

FWIW: changed to chmod 700 but makes no difference.

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: server drops key recognition

Post by TrevorH » 2015/05/24 16:31:47

Post the output of (after amending youruser to the correct username)

Code: Select all

ls -ldZ /home /home/youruser /home/youruser/.ssh
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

zuser
Posts: 19
Joined: 2013/12/31 16:34:24

Re: server drops key recognition

Post by zuser » 2015/05/24 19:53:38

TrevorH wrote:Post the output of (after amending youruser to the correct username)

Code: Select all

ls -ldZ /home /home/youruser /home/youruser/.ssh
As follows:

[wlz@snowman ~]$ ls -ldZ /home /home/wlz /home/wlz/.ssh
drwxr-xr-x. root root system_u:object_r:home_root_t:s0 /home
drwxr--r--. wlz wlz unconfined_u:object_r:user_home_dir_t:s0 /home/wlz
drwx------ wlz wlz ? /home/wlz/.ssh

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: server drops key recognition

Post by TrevorH » 2015/05/24 21:56:44

What is the output of getenforce
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

stevemowbray
Posts: 519
Joined: 2012/06/26 14:20:47

Re: server drops key recognition

Post by stevemowbray » 2015/05/25 10:52:19

If I immediately return to client, I can ssh to server and/or run scripts to rsync via ssh w/o password but after a few minutes, additional attempts to ssh to server result in request for password.
What exactly are you rsyncing? Maybe that's what's changing the permissions, if you are rsyncing to the home directory?

zuser
Posts: 19
Joined: 2013/12/31 16:34:24

Re: server drops key recognition

Post by zuser » 2015/05/25 13:11:41

TrevorH wrote:What is the output of getenforce

Disabled

Post Reply