io:fwrite("Automatic login\n").
ENG ( Link to Portuguese versiao )
I hope that you have nice fun with RaspberryPI @ your lab (link). From this post you can learn how to set-up automatic login. Our goal is to avoid passphrases, use public-key with YubiKey. There are a few question that you should answer (my answer for the lab):
- do need password for public-key? (no; this is lab environment); - do you need pin for your YubiKey? (no; for lab is enough to have PublicKey & YubiKey); - do you wan to storage key @Yubikey? (no; it would enable easy login from different machines but if someone get YubiKey he has everything); - do you need to touch YubiKey for login? (yes; I just like iteration with physical world :-) ).
I test PopOS on the desktop, ArchLinux on RaspberryPi.
As always, the greatest documentation can be find on ArchWiki: OpenSSH, SSH Keys.
Lets start from the desktop site, based on https://developers.yubico.com/libfido2/ we install prerequisite packages:
sudo apt install libfido2-1 libfido2-dev libfido2-doc fido2-tools
Next we plugin YubiKey and generate publickey:
ssh-keygen -t ed25519-sk -C "$(whoami)@$(uname -n)-$(date -I)-yubikey-XYZ"
For make my life easy I use physical number of YubiKey as XYZ. According to my answer on top: I skipped passphrase and options resident and no-touch-required.
Next we copy publickey at out RespberryPi:
ssh-copy-id -i .ssh/id_ed25519_sk.pub username@raspberry_IP
During the operation you would be asked (last time!) for your classical password.
Arch have not so bad default configuration, so you can test it already:
Try ssh username@raspberrypiIP and the only thing that you should do should be touching your Yubikey.
In case that your SSHD conf is already modify, please focuse on following options in your rasberrypi's /etc/ssh/sshd_config:
PermitRootLogin no
PubkeyAuthentication yes
Remember, that now you always need to have YubiKey to access the server. For enlarge your comfort zone you should add second publickey with second YubiKey that you will storage on safe place, just in case of emergency.
PT
Espero que te divirtas com RaspberryPI @ seu Lab (link). A partir deste post você pode aprender como configurar o login automático. Nosso objetivo é evitar senhas, use a chave pública com o YubiKey. Há algumas perguntas que você deve responder (minha resposta para o laboratório):
- precisa de senha para chave publica? (nao); - voce precisa de PIN para o seu YubiKey? (nao); - voce quer a chave de armazenamento @YubiKey (nao) - voce quer precisa tocar no YubiKey para fazer login (sim)
Eu testo o PopOS no desktop e ArchLinux no RasbrerryPi.
Como sempre, a maior documentacao pode ser encontrada no ArchWiki: OpenSSH, SSH Keys.
Vamos comesar pelo site desktop, basedo em https://developers.yubico.com/libfido2/ instalamos pacotes de pre-requisitos:
sudo apt install libfido2-1 libfido2-dev libfido2-doc fido2-tools
Em seguida, plugamos o YubiKey e geramos a chave publica:
ssh-keygen -t ed25519-sk -C "$(whoami)@$(uname -n)-$(date -I)-yubikey-XYZ"
Para facilitar minha vida, eu uso numero fisico do YubiKey como XYZ. De acordo com minha resposta no topu: eu pulei a senha e as opcoes residentes e sem necessidade de toque.
Em seguida, copiamos a chave publica em RaspberryPi:
ssh-copy-id -i .ssh/id_ed25519_sk.pub username@raspberry_IP
Durante a operacao, voce sera solicitado (pela ultima vez!) pela sua senha classica
O Arch nao tem uma configuracao padrao tao ruim, entao voce ja pode testa-lo:
Tente ssh username@raspberrypiIP e a unica coisa que voce deve fazer deve ser tocar no seu YubiKey.
Caso seu SSHD conf ja esteja modificado, concentre-se nasd sequintes opcoes no /etc/ssh/sshd_config:
PermitRootLogin no
PubkeyAuthentication yes
Lembre-se de que agora você sempre precisa ter o YubiKey para acessar o servidor. Para aumentar sua zona de conforto, você deve adicionar uma segunda chave pública com a segunda YubiKey que você armazenará em local seguro, apenas em caso de emergência.