Configurar SSH en MacBook M1 para GitHub

Guía paso a paso para configurar SSH en MacBook M1 y GitHub: genera una clave ed25519, añádela al ssh-agent y al llavero, registra la clave pública en GitHub y usa SSH en tus repos.

8 sept 2025 • 5 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

Configurar SSH en MacBook M1 para GitHub

Resumen rápido de lo que harás

1. Comprobar si ya tienes claves SSH

2. Crear una clave SSH ed25519 recomendada

3. Añadir la clave al ssh-agent y guardarla en el Llavero de macOS

4. Registrar la clave pública en tu cuenta de GitHub

5. Configurar ~/.ssh/config para que tu clave se cargue automáticamente

6. Probar la conexión y migrar repos existentes a SSH

Por qué SSH

SSH permite que tu Mac se autentique con GitHub sin escribir usuario y contraseña o tokens en cada git push. Es seguro, rápido y el estándar para desarrolladores, clave en buenas prácticas de ciberseguridad.

1) Comprueba si ya tienes claves

En Terminal ejecuta

ls -al ~/.ssh

Si no existe la carpeta o no ves id_ed25519 o id_rsa, puedes crear una nueva clave. Si ves claves que deseas conservar, anota sus nombres.

2) Genera una nueva clave ed25519

ed25519 es moderna y compacta. Sustituye tu_email@ejemplo.com por tu email de GitHub

ssh-keygen -t ed25519 -C tu_email@ejemplo.com

Cuando te pregunte el archivo donde guardar, pulsa Enter para aceptar el valor por defecto ~/.ssh/id_ed25519 a menos que necesites múltiples claves. Añade una frase de paso para más seguridad recomendado o deja en blanco con Enter.

Si tu sistema no soporta ed25519 usa RSA 4096

ssh-keygen -t rsa -b 4096 -C tu_email@ejemplo.com

3) Inicia el ssh-agent y añade tu clave

Inicia el agente en tu sesión de shell

eval $(ssh-agent -s)

Añade la clave privada al agente y en macOS guarda la frase de paso en el Llavero para no repetirla

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

En macOS anteriores a Monterey usa

ssh-add -K ~/.ssh/id_ed25519

O bien un añadido simple sin comportamiento de llavero

ssh-add ~/.ssh/id_ed25519

Si ssh-add --apple-use-keychain falla por ejemplo ssh-add: illegal option -- apple-use-keychain probablemente estás usando un ssh-add no nativo de Apple como OpenSSH de Homebrew. Comprueba qué binario se usa con which ssh-add y ejecuta /usr/bin/ssh-add --apple-use-keychain ~/.ssh/id_ed25519 o ajusta la instalación de Homebrew.

4) Configura ~/.ssh/config para que macOS use tu clave automáticamente

Crea o edita ~/.ssh/config y añade estas líneas

Host github.com

HostName github.com

User git

AddKeysToAgent yes

UseKeychain yes

IdentityFile ~/.ssh/id_ed25519

Esto es especialmente útil si usas múltiples claves o si quieres que el Llavero recuerde frases de paso.

5) Copia la clave pública y añádela a GitHub

Para copiar al portapapeles en macOS

pbcopy < ~/.ssh/id_ed25519.pub

O muéstrala para copiar manualmente

cat ~/.ssh/id_ed25519.pub

En GitHub ve a Configuración luego SSH and GPG keys y pulsa New SSH key. Pon un título descriptivo como MacBook-M1 y pega la clave.

6) Prueba la conexión

ssh -T git@github.com

Si todo va bien verás algo como

Hi <tu-usuario> You have successfully authenticated, but GitHub does not provide shell access.

Si aparece Permission denied publickey revisa la sección de resolución de problemas.

7) Cambia un repo existente a SSH

Dentro del repositorio

git remote -v

Si muestra https cámbialo a ssh

git remote set-url origin git@github.com:USUARIO/REPO.git

O clona directamente con SSH

git clone git@github.com:USUARIO/REPO.git

Resolución de problemas

ssh-add: illegal option -- apple-use-keychain

Causa ssh-add instalado desde Homebrew u otra fuente no incluye la opción específica de Apple --apple-use-keychain

Solución ejecuta which ssh-add para ver el binario. El de Apple está en /usr/bin/ssh-add. Llámalo directamente o ajusta PATH para usar el de Apple. Consulta man ssh-add para comportamiento de Keychain en macOS.

Permission denied publickey

Causas comunes

La clave privada no está cargada en el agente. Lista las claves con ssh-add -l

Permisos incorrectos en ~/.ssh o en los archivos de clave. Corrige con

chmod 700 ~/.ssh

chmod 600 ~/.ssh/id_ed25519

chmod 644 ~/.ssh/id_ed25519.pub

Añadiste la clave pública incorrecta a GitHub. Vuelve a copiar con pbcopy < ~/.ssh/id_ed25519.pub

El remoto sigue en HTTPS. Compruébalo con git remote -v

Salida de depuración detallada

ssh -vT git@github.com

Varios perfiles de GitHub personal y trabajo

Si necesitas claves separadas crea dos

ssh-keygen -t ed25519 -C personal@ejemplo.com -f ~/.ssh/id_ed25519_personal

ssh-keygen -t ed25519 -C trabajo@ejemplo.com -f ~/.ssh/id_ed25519_work

Luego en ~/.ssh/config

Host github-personal

HostName github.com

User git

IdentityFile ~/.ssh/id_ed25519_personal

AddKeysToAgent yes

UseKeychain yes

Host github-work

HostName github.com

User git

IdentityFile ~/.ssh/id_ed25519_work

AddKeysToAgent yes

UseKeychain yes

Usa el alias al clonar o al configurar remotos por ejemplo

git clone git@github-personal:tuusuario/turepo.git

git remote set-url origin git@github-work:tuorg/repo.git

Notas extra para Apple Silicon M1

En Apple Silicon Homebrew se instala por defecto en /opt/homebrew y puede traer ssh y ssh-add en /opt/homebrew/bin que no soportan las banderas específicas de Apple. Si te falla --apple-use-keychain verifica con which ssh-add y usa /usr/bin/ssh-add cuando sea necesario.

zsh es la shell por defecto en macOS moderno. Si quieres que las claves se carguen tras iniciar sesión añade a tu archivo ~/.zshrc una línea como ssh-add --apple-load-keychain ~/.ssh/id_ed25519 2>/dev/null o usa ssh-add --apple-use-keychain según tu versión.

Checklist final

- Clave generada en ~/.ssh/id_ed25519

- Clave añadida al ssh-agent y almacenada en el Llavero

- Clave pública pegada en GitHub

- Conexión verificada con ssh -T git@github.com

- Remotos actualizados a SSH

En Q2BSTUDIO somos una empresa de desarrollo de software con foco en calidad, seguridad y escalabilidad. Diseñamos aplicaciones a medida y software a medida, integramos inteligencia artificial y agentes IA en procesos críticos, fortalecemos ciberseguridad y ayudamos a implantar servicios cloud AWS y Azure, además de impulsar la toma de decisiones con servicios inteligencia de negocio y power bi. Si buscas un partner para crear productos digitales robustos y seguros, descubre cómo abordamos proyectos de aplicaciones a medida en desarrollo de aplicaciones y software multiplataforma. Y si quieres elevar la postura de seguridad de tu organización con auditorías, hardening y pentesting orientado a riesgos, visita nuestra página de ciberseguridad y pentesting. También impulsamos ia para empresas con casos de uso prácticos que integran modelos, automatización de procesos y BI para maximizar el retorno.

Palabras clave sugeridas para mejorar el posicionamiento aplicaciones a medida, software a medida, inteligencia artificial, ciberseguridad, servicios cloud aws y azure, servicios inteligencia de negocio, ia para empresas, agentes IA, power bi.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.

Live Chat