Debian SSH Worksheet: Key-Only Login and Active Sessions
Follow along with Shorts 5 and 6 from WrongWords On Porpoise. Run the PowerShell commands on Windows and the Bash commands on Debian. Replace the example username and IP address with your own. The exercises assume OpenSSH on Debian, a working SSH key and sudo access.
Short 5 · Switch SSH to key-only login
1. Prove your key works. Open the Proxmox console or another recovery console. From PowerShell, connect with your key and run sudo whoami on Debian. Expect root. Then type exit.
ssh -o ControlPath=none -o PreferredAuthentications=publickey YOUR_USER@YOUR_SERVER_IP
2. Check password login before the change. On a demo VM that still allows password login, use the following command. Keep this session open. If password login is already refused, keep a working key session open and skip the before test.
ssh -o ControlPath=none -o PubkeyAuthentication=no -o PreferredAuthentications=password,keyboard-interactive YOUR_USER@YOUR_SERVER_IP
3. Write the settings on Debian. Check that /etc/ssh/sshd_config includes /etc/ssh/sshd_config.d/*.conf. Use the example filename only if it is available or is already your dedicated worksheet file. The command replaces that file and the settings apply globally.
printf '%s\n' \
'PubkeyAuthentication yes' \
'PasswordAuthentication no' \
'KbdInteractiveAuthentication no' |
sudo tee /etc/ssh/sshd_config.d/0-wwop-key-only.conf
4. Check and reload. The effective settings should show public key authentication as yes and the other two as no. If your configuration uses Match rules, check the settings for your actual connection with sshd -T -C before reloading.
sudo /usr/sbin/sshd -T |
grep -E '^(pubkeyauthentication|passwordauthentication|kbdinteractiveauthentication) '
sudo /usr/sbin/sshd -t && sudo systemctl reload ssh
5. Test from a second PowerShell window. Repeat the password-only test from step 2. Expect a refusal. Then repeat the key-only command from step 1. A private-key passphrase prompt is handled on your PC. Close your original session once the fresh key login works. If you lose fresh access, use the existing session or console to remove the new drop-in or restore its previous contents, then validate and reload again.
Record your results. Password refused __________ · Fresh key login works __________
Short 6 · See who is logged into Debian
Open two PowerShell windows and run the following command in each, or reuse two working interactive SSH sessions.
ssh -o ControlPath=none YOUR_USER@YOUR_SERVER_IP
Run these on Debian in one of the sessions.
sudo ss -lntp
ss -tn state established '( sport = :22 )'
w
who -u
sudo ss -lntplists listening TCP ports and their processes. Look for SSH on port 22.- The filtered
sscommand lists established TCP connections to the server’s local port 22. Two connections from your PC can have the same peer IP and different client ports. Use your actual SSH port if it differs. wshows terminal logins. Check the username, terminal and source. A local console session can appear alongside SSH sessions.who -ushows the login time and idle time. Use the login time to see how long the session has been open.
Type exit in one SSH window and repeat the checks in the other. Record what changed. SSH connections before __________ · After __________ · Console login time, if shown __________
Debian OpenSSH configuration · Debian ss reference · Debian w reference
[…] Debian SSH command worksheet for Shorts 5 and 6 […]