Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

Lab 5.1RHCSA 10, Hoofdstuk 5

Log in from server1 to server2 with an SSH key

Niveau
Makkelijk
20 min
Machines
server1, server2
Status
Nog niet begonnen

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Doel

Set up key-based login so that student on server1 can log in to server2 without a password, and run commands there.

Voordat je begint

  • Both machines run and can reach each other by name (see lab 8.1, or use the IP addresses).
  • The user student exists on both machines with a password.

Taken

  1. On server1, as student, make an Ed25519 key pair. Use an empty passphrase for this lab.
  2. Copy the public key to student on server2.
  3. Log in to server2 without a password and show the hostname.
  4. From server1, run the command uptime on server2 without opening an interactive shell.
  5. Check that the permissions of ~/.ssh and ~/.ssh/authorized_keys on server2 are correct.

Controleer je werk

ssh -o BatchMode=yes student@server2 hostname
ssh student@server2 'stat -c "%a %n" ~/.ssh ~/.ssh/authorized_keys'
  • The first command prints server2.example.com and does not ask for a password (BatchMode makes it fail instead of asking).
  • The permissions are 700 for ~/.ssh and 600 for authorized_keys.

Hints

Toon de hints

Oplossing

Toon de oplossing
  1. Make the key.
    ssh-keygen -t ed25519 -N "" -f ~/.ssh/id_ed25519
  2. Copy the public key.
    ssh-copy-id student@server2
  3. Log in and check.
    ssh student@server2
    hostname
    exit
  4. Run one remote command.
    ssh student@server2 uptime
  5. Check and, if needed, fix the permissions on server2.
    ssh student@server2 'chmod 700 ~/.ssh; chmod 600 ~/.ssh/authorized_keys'

Mijn notities

Nog geen notities.

Lessen voor dit lab

Commando's in dit lab