SSH_automate_Debian/README.md
2025-10-03 21:30:21 +08:00

70 lines
1.7 KiB
Markdown

# SSH key per entrare in automatico su un ssh client
[orig link](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)
Creare la key dal quale si vuole entrare con SSH senza login (x es 192.168.1.3)
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "Coppia chiavi SSH di tuo nome"
Copiarle sul client dove si vuole entrare (x es. 192.168.1.4)
ssh-copy-id orangepi@192.168.1.4
Far partire ssh-agent
eval `ssh-agent -s`
Aggiungere la chiave
ssh-add .ssh/id_ed25519
collegarsi con
ssh -p 22 -I ~/.ssh/id_ed25519 orangepi@192.168.1.4
oppure se la porta rimane la standard (22) e la chiave è unica basta anche solo
ssh orangepi@192.168.1.4
se si è digitata una password e la vi suole cambiare o eliminare (enter senza digitare niente)
ssh-keygen -p -f ~/.ssh/id_ed25519
### Caricare in automatico SSH agent per tutti gli utenti
[orig link](https://www.baeldung.com/linux/ssh-agent-systemd-unit-configure)
copiare il file ssh-agent.service
sudo cp ssh-agent.service /etc/systemd/system/ssh-agent.service
editare il file
sudo nano /etc/environment
e in fondo inserire
SSH_AUTH_SOCK=/run/user/$(id -u)/ssh-agent.socket
o
sudo nano /etc/environment.d/ssh_auth_socket.conf
e in fondo inserire
SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/ssh-agent.socket"
se la versione SSH è maggiore di 7,2 inserire
echo 'AddKeysToAgent yes' >> ~/.ssh/config
This will instruct the ssh client to always add the key to a running agent
avviare il sistema
sudo systemctl daemon-reload
sudo systemctl enable ssh-agent.service
sudo systemctl start ssh-agent.service
sudo systemctl status ssh-agent.service