1.8 KiB
1.8 KiB
RHCSA 10.3: SSH key-based authentication
Key-based login to another system, turning off password logins there, and
what sshd does when authorized_keys is too open.
Before you start
The lab creates users student and alice (password Lab-Pass-1), and a
second machine, server1 (10.99.0.2), to log in to. server1 shares
this VM's files and users, and runs its own sshd, with its own
configuration so this VM's SSH logins aren't touched:
- configuration:
/etc/ssh/server1/sshd_config, which reads/etc/ssh/server1/sshd_config.d/*.conffirst; - service:
le-lab-server1-sshd(restart it after a change, and read its log withjournalctl -u le-lab-server1-sshd); - test the configuration with
sshd -t -f /etc/ssh/server1/sshd_configandsshd -T -f /etc/ssh/server1/sshd_config.
server1 allows password logins to start with.
Tasks
- Set up key-based login for user
studentto useraliceonserver1: asstudent,ssh -o BatchMode=yes alice@server1 whoamiprintsalicewithout asking anything. - Turn off password logins for SSH on
server1, and confirm keys still work:ssh -o PubkeyAuthentication=no alice@server1fails with "Permission denied (publickey...)". - Make
alice'sauthorized_keyswritable by her group (mode620), and see what happens to the key login and in sshd's log; then fix it.
Hints
- As
student(su - student):ssh-keygen, thenssh-copy-id alice@server1(alice's password isLab-Pass-1). PasswordAuthentication noin a file in/etc/ssh/server1/sshd_config.d/;systemctl restart le-lab-server1-sshd;sshd -T -f /etc/ssh/server1/sshd_config | grep -i passwordauthentication.chmod 620 ~alice/.ssh/authorized_keys;journalctl -u le-lab-server1-sshdshows "bad ownership or modes";chmod 600.