Configurar SSH en MacBook M1 y conectar a GitHub

Guía paso a paso para configurar SSH en MacBook M1 y conectar GitHub sin contraseñas: generar claves ed25519, cargar con ssh-agent y migrar repos a SSH. Potencia DevSecOps con Q2BSTUDIO.

8 sept 2025 • 4 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

Configurar SSH en MacBook M1 y conectar a GitHub de forma segura y sin contraseñas en cada push. En Q2BSTUDIO, empresa de desarrollo de software, aplicaciones a medida, especialistas en inteligencia artificial y ciberseguridad, acompañamos a equipos técnicos para acelerar su flujo de trabajo con buenas prácticas DevSecOps. Si buscas potenciar tu stack con aplicaciones a medida o integrar agentes IA, contáctanos.

TLDR lo que harás

1 Revisar si ya tienes claves SSH. 2 Crear una nueva clave ed25519 recomendada. 3 Añadir la clave al ssh-agent y al llavero de macOS. 4 Agregar la clave pública a tu cuenta de GitHub. 5 Configurar ~/.ssh/config para cargar la clave automáticamente. 6 Probar la conexión y migrar repos existentes a SSH.

Por qué SSH

SSH permite autenticarte con GitHub sin usuario ni contraseña en cada push, es seguro, rápido y estándar para desarrolladores.

1 Comprobar claves existentes

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 Generar una nueva clave ed25519 recomendada

Comando: ssh-keygen -t ed25519 -C your_email@example.com. Acepta la ruta por defecto ~/.ssh/id_ed25519 o define otra si necesitas múltiples claves. Añade una passphrase para más seguridad recomendado o déjala vacía si lo prefieres. Si ed25519 no está disponible, usa RSA: ssh-keygen -t rsa -b 4096 -C your_email@example.com.

3 Iniciar ssh-agent y agregar tu clave

Inicia el agente: eval $(ssh-agent -s). Añade la clave y guarda la passphrase en el llavero de macOS para no repetirla: ssh-add --apple-use-keychain ~/.ssh/id_ed25519. En macOS antiguos: ssh-add -K ~/.ssh/id_ed25519. Alternativa simple sin llavero: ssh-add ~/.ssh/id_ed25519.

Si aparece ssh-add illegal option -- apple-use-keychain probablemente usas la versión de OpenSSH de Homebrew. Revisa con which ssh-add y usa directamente /usr/bin/ssh-add --apple-use-keychain ~/.ssh/id_ed25519 o ajusta tu PATH.

4 Configurar ~/.ssh/config para cargar la clave automáticamente

Edita ~/.ssh/config y añade estas líneas en bloque: Host github.com; HostName github.com; User git; AddKeysToAgent yes; UseKeychain yes; IdentityFile ~/.ssh/id_ed25519. Esto recuerda passphrases y simplifica el uso si manejas varias claves.

5 Copiar la clave pública y añadirla a GitHub

Copiar al portapapeles en macOS: pbcopy < ~/.ssh/id_ed25519.pub. O mostrar en pantalla: cat ~/.ssh/id_ed25519.pub. En GitHub ve a Settings, SSH and GPG keys y pulsa New SSH key. Pon un título descriptivo como MacBook-M1 y pega la clave.

6 Probar la conexión

Ejecuta: ssh -T git@github.com. Si todo va bien verás un mensaje de autenticación correcta indicando que GitHub no ofrece acceso shell. Si aparece Permission denied publickey pasa a la sección de solución de problemas.

7 Cambiar un repositorio existente a SSH o clonar por SSH

Comprueba el remoto: git remote -v. Si ves https cambia a SSH: git remote set-url origin git@github.com:USERNAME/REPO.git. Para clonar con SSH: git clone git@github.com:USERNAME/REPO.git.

Solución de problemas

Error ssh-add illegal option -- apple-use-keychain. Causa versión no Apple de ssh-add. Solución ejecuta which ssh-add y usa la ruta de Apple en /usr/bin/ssh-add o ajusta Homebrew.

Permission denied publickey

Posibles causas y soluciones: 1 La clave privada no está cargada en el agente. Comprueba con ssh-add -l. 2 Permisos incorrectos. Arregla con chmod 700 ~/.ssh; chmod 600 ~/.ssh/id_ed25519; chmod 644 ~/.ssh/id_ed25519.pub. 3 Clave pública incorrecta pegada en GitHub. Copia de nuevo con pbcopy < ~/.ssh/id_ed25519.pub. 4 El remoto sigue en HTTPS. Verifica con git remote -v.

Depuración en modo detallado

Lanza ssh -vT git@github.com para ver qué clave se ofrece y por qué falla.

Varios usuarios de GitHub personal y trabajo

Crea dos claves: ssh-keygen -t ed25519 -C personal@example.com -f ~/.ssh/id_ed25519_personal y ssh-keygen -t ed25519 -C work@example.com -f ~/.ssh/id_ed25519_work. En ~/.ssh/config añade dos bloques: 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. Al clonar o cambiar remotos usa los alias de host, por ejemplo git clone git@github-personal:usuario/repositorio.git o git remote set-url origin git@github-work:organizacion/repo.git.

Notas extra para Apple Silicon M1

Homebrew en M1 se instala en ruta por defecto /opt/homebrew y puede instalar versiones de ssh y ssh-add en /opt/homebrew/bin sin las banderas de Apple. Si hay problemas con --apple-use-keychain revisa which ssh-add y usa /usr/bin/ssh-add cuando sea necesario. En macOS moderno la shell por defecto es zsh. Si quieres cargar claves tras iniciar sesión añade a tu archivo ~/.zshrc una de estas líneas según tu entorno: ssh-add --apple-use-keychain ~/.ssh/id_ed25519 2>/dev/null o ssh-add --apple-load-keychain ~/.ssh/id_ed25519 2>/dev/null.

Checklist final

- Generaste una clave en ~/.ssh/id_ed25519. - Añadiste la clave al ssh-agent y al llavero de macOS. - Pegaste la clave pública en GitHub. - Confirmaste ssh -T git@github.com funciona. - Actualizaste los remotos a SSH.

Impulsa tu equipo con Q2BSTUDIO

En Q2BSTUDIO construimos aplicaciones a medida y software a medida con foco en seguridad, escalabilidad y experiencia de desarrollador. Si necesitas reforzar tu pipeline con prácticas de ciberseguridad y pentesting, consulta nuestros servicios en ciberseguridad y pentesting. Además, si tu empresa quiere acelerar su roadmap digital con soluciones robustas, descubre nuestro desarrollo de software a medida.

SEO y capacidades

Nuestro portfolio abarca inteligencia artificial, ia para empresas, agentes IA, servicios cloud aws y azure, servicios inteligencia de negocio y power bi, además de automatización de procesos y gobierno de datos. Integramos estas capacidades en tus proyectos de GitHub y CI CD para que la seguridad y el rendimiento vayan de la mano.

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