Skip to content

Instantly share code, notes, and snippets.

@amicojeko
Created November 6, 2025 08:33
Show Gist options
  • Select an option

  • Save amicojeko/66bc00b3a3a08f78bcfe24ad7771d693 to your computer and use it in GitHub Desktop.

Select an option

Save amicojeko/66bc00b3a3a08f78bcfe24ad7771d693 to your computer and use it in GitHub Desktop.
Aggiungere chiavi SSH esistenti al nuovo Mac

Aggiungere chiavi SSH esistenti al nuovo Mac

🔧 1. Copia le chiavi sul nuovo Mac

Se le hai su un altro computer:

scp -r user@old-mac:~/.ssh ~/.ssh

Oppure, se le hai su una chiavetta o drive, copiale manualmente nella cartella:

/Users/<tuo_utente>/.ssh/

Imposta i permessi corretti:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_*

🧩 2. Aggiungi le chiavi all’agent SSH

Avvia l’agent (se non è già in esecuzione):

eval "$(ssh-agent -s)"

Poi aggiungi la tua chiave:

ssh-add ~/.ssh/id_rsa

(o id_ed25519 se usi Ed25519)


⚙️ 3. Configura il caricamento automatico

Apri o crea il file ~/.ssh/config:

nano ~/.ssh/config

E aggiungi queste righe:

Host *
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_rsa

Salva con CTRL+O, poi ENTER, ed esci con CTRL+X.


🔁 4. Carica la chiave nel keychain macOS

Così non ti chiede più la passphrase:

ssh-add --apple-use-keychain ~/.ssh/id_rsa

🧠 5. (Facoltativo) Verifica che funzioni

Chiudi il terminale, riaprilo e prova:

ssh -T git@github.com

Se vedi un messaggio di benvenuto, tutto funziona correttamente.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment