Gentoo Archives: gentoo-user

From: Alan McKinnon <alan.mckinnon@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Locking down a user with a shell account and SSH access
Date: Thu, 18 Jul 2013 18:35:27
Message-Id: 51E834D7.9020403@gmail.com
In Reply to: Re: [gentoo-user] Locking down a user with a shell account and SSH access by Grant
1 On 18/07/2013 18:21, Grant wrote:
2 >>>>> My backup user needs a shell on the backup server in order to execute
3 >>>>> rsync and needs to be included in /etc/ssh/sshd_config AllowUsers in
4 >>>>> order to SSH in. My authorized_keys file is locked-down. The second
5 >>>>> field for the user in /etc/shadow is an exclamation point which I
6 >>>>> think means the user can not log in with a password. Should I take
7 >>>>> any additional steps to prevent that user from logging in and not
8 >>>>> being subject to the authorized_keys restrictions?
9 >>>>
10 >>>> What about "PasswordAuthentication no"?
11 >>>
12 >>> Can that be set for a single user? I have a normal user who needs to
13 >>> log in via SSH with a password and a backup user who only needs to run
14 >>> rsync via SSH keys. If not, does the exclamation point in /etc/shadow
15 >>> prevent the user from logging in without the SSH key?
16 >>
17 >> Depends.
18 >>
19 >> The user doesn't have a Unix password, so if the system prompts for one
20 >> it cannot succeed and the login fails.
21 >>
22 >> But sshd has other implementations for authentication to, not just
23 >> classic Unix. If it uses PAM, then PAM could in theory do anything, even
24 >> using AD to authenticate with a password.
25 >>
26 >> So if your sshd config uses Unix passwords and keys ONLY (this is the
27 >> norm), then what you describe above does what you want. To be sure, you
28 >> need to audit sshd_config and your pam setup
29 >
30 > Here is my entire sshd_config:
31 >
32 > PasswordAuthentication no
33 > UsePAM yes
34 > PrintMotd no
35 > PrintLastLog no
36 > Subsystem sftp /usr/lib64/misc/sftp-server
37 > AllowUsers user1 user2
38 >
39 > That must be the Gentoo-default except for the last line, correct?
40 > How is this config if I want user1 to login with a password and user2
41 > has no password in /etc/shadow and automatically logs in via
42 > authorized_keys to rsync?
43
44
45 Gentoo default uses a conventional PAM setup so set
46
47 PasswordAuthentication yes
48 PubkeyAuthentication yes
49
50 and it should work.
51
52 I don't know of any way to configure per-user auth types in sshd_config
53 itself, so I recommend you define exactly what you want to accomplish:
54
55 do you want to give one user a password and no key, and the other user a
56 key but no password, and have it just work regardless? This would be the
57 "convenience" approach
58
59 or do you want to enforce the auth method that a specific user must use?
60 This would be the "security" approach and is considerably more difficult
61
62
63
64 --
65 Alan McKinnon
66 alan.mckinnon@×××××.com