26
loading...
This website collects cookies to deliver better user experience
sudo apt update && apt upgrade && reboot
adduser username
usermod -aG sudo username
su username
sudo apt install libpam-google-authenticator
google-authenticator
binary to create a new secret key (keep this one safe).google-authenticator
Do you want authentication tokens to be time-based (y/n) y
Do you want me to update your "/home/username/.google_authenticator" file? (y/n) y
Do you want to disallow multiple uses of the same authentication
token? This restricts you to one login about every 30s, but it increases
your chances to notice or even prevent man-in-the-middle attacks (y/n) n
By default, a new token is generated every 30 seconds by the mobile app.
In order to compensate for possible time-skew between the client and the server,
we allow an extra token before and after the current time. This allows for a
time skew of up to 30 seconds between authentication server and client. If you
experience problems with poor time synchronization, you can increase the window
from its default size of 3 permitted codes (one previous code, the current
code, the next code) to 17 permitted codes (the 8 previous codes, the current
code, and the 8 next codes). This will permit for a time skew of up to 4 minutes
between client and server.
Do you want to do so? (y/n) y
If the computer that you are logging into isn't hardened against brute-force
login attempts, you can enable rate-limiting for the authentication module.
By default, this limits attackers to no more than 3 login attempts every 30s.
Do you want to enable rate-limiting? (y/n) y
sudo vim /etc/pam.d/sshd
# Standard Un*x password updating.
@include common-password
+ auth required pam_google_authenticator.so
sudo vim /etc/ssh/sshd_config
// We created a non-root user with sudo privileges earlier, so we can disable
- PermitRootLogin yes
+ PermitRootLogin no
- ChallengeResponseAuthentication no
+ ChallengeResponseAuthentication yes
// Restart to pick up changes
sudo systemctl restart sshd
lsb_release -d && ssh -V
Description: Ubuntu 20.04.2 LTS
OpenSSH_8.2p1 Ubuntu-4ubuntu0.2, OpenSSL 1.1.1f 31 Mar 2020
ecdsa-sk
or ed25519-sk
. Please note that ed25519-sk
only works if your YubiKey runs on Firmware >=5.2.3
.ykman
or YubiKey manager
.brew install ykman
ykman list
Firmware version: 5.2.7
// Using ed25519-sk since Firmware of my YubiKey >=5.2.3
// macOS may throw "unknown key type ed25519-sk", run "brew install openssh" to fix this issue
ssh-keygen -t ed25519-sk -f ~/.ssh/$(hostname)-yk_id
You may need to touch your authenticator to authorize key generation
~/.ssh/authorized_keys
.ssh-copy-id -i ~/.ssh/hostname-yk_id username@IP
ssh -i ~/.ssh/hostname-yk_id username@IP