1.6 KiB
1.6 KiB
Using Linux Terminal 3.1: SSH keys
An Ed25519 key with a passphrase, installing it for another user by hand, and what sshd does when a home directory is too open.
Before you start
The lab creates user student (password Lab-Pass-1). Make the key as
student (sudo -iu student); use sudo for the steps that need root.
Give the key the passphrase Lab-Phrase-1: le-lab check needs it to
test the login. The lab checks that user bob doesn't exist yet, and
le-lab reset removes him and ~/.ssh/lab_key.
Tasks
- Make an Ed25519 key pair with a passphrase and the comment
lab-key, saved as~/.ssh/lab_key. - Create a user
bobwith a password, then install your lab key for him so you can log in tobob@localhostwith it. Ubuntu cloud images turn off password logins over SSH, so ssh-copy-id can't log in there; use the manual steps instead. Aftereval "$(ssh-agent)"; ssh-add ~/.ssh/lab_key,ssh -o BatchMode=yes -o StrictHostKeyChecking=accept-new -i ~/.ssh/lab_key bob@localhost whoamiprintsbob. - Run
sudo chmod 777 /home/bob, try the login again, and find out why it fails. Then fix it.
Hints
ssh-keygen -t ed25519 -C lab-key -f ~/.ssh/lab_key;ssh-keygen -l -f.useradd -m,passwd; then/home/bob/.ssh(mode 700) andauthorized_keys(mode 600), both owned bybob, holding the.publine. BatchMode doesn't ask about a new host key either: withoutaccept-new, the first try fails with "Host key verification failed."journalctl -u ssh -n 5or/var/log/auth.log: "bad ownership or modes";chmod 750 /home/bob.