Claves SSH en Windows: arreglar errores de clave privada no protegida

Guía para usar claves SSH en Windows sin el error Unprotected Private Key File: toma propiedad, elimina herencia y ACL amplios, y concede solo lectura a tu cuenta; guarda las llaves en .ssh y conecta a EC2 de forma segura.

31 ago 2025 • 3 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

Using SSH Keys on Windows: Fixing Unprotected Private Key File Errors. Cuando usas SSH para conectar con una instancia EC2, el cliente comprueba los permisos del archivo de clave privada PEM. En Linux o macOS esto se aplica con chmod 400 solo lectura para el propietario. En Windows con OpenSSH, la misma verificación se hace mediante permisos NTFS ACL. Si el archivo es accesible por grupos como Authenticated Users, Users o Everyone, SSH se negará a usarlo y mostrará el error Unprotected Private Key File.

Concepto clave: una clave privada debe ser de tu propiedad y solo legible por ti. En Windows eso se controla con ACL y no con chmod. Para corregirlo debes tomar la propiedad del archivo y restringir sus ACL para que solo tu cuenta y de forma opcional SYSTEM y Administrators puedan leerlo. Es el equivalente Windows de chmod 400.

Paso 1 Tomar propiedad

Si descargaste o copiaste el archivo desde otro sistema, la propiedad puede no pertenecer a tu cuenta.

Comando: takeown /F D:\3-tier-web-arch\nfs-key.pem

Paso 2 Quitar herencia

Evita que el archivo herede permisos amplios de la carpeta.

Comando: icacls D:\3-tier-web-arch\nfs-key.pem /inheritance:r

Paso 3 Eliminar grupos amplios

Elimina grupos predeterminados de Windows que vuelven el archivo accesible para otros.

Comando: icacls D:\3-tier-web-arch\nfs-key.pem /remove:g Authenticated Users Users Everyone

Paso 4 Conceder solo el acceso necesario

Otorga a tu cuenta permiso de lectura y opcionalmente deja a SYSTEM y Administrators con control total.

Comandos: icacls D:\3-tier-web-arch\nfs-key.pem /grant DESKTOP-ABCD\Amanda:R

icacls D:\3-tier-web-arch\nfs-key.pem /grant SYSTEM:F Administrators:F

Paso 5 Verificar

Comando: icacls D:\3-tier-web-arch\nfs-key.pem

Salida esperada

DESKTOP-ABCD\Amanda:(R)

BUILTIN\Administrators:(F)

NT AUTHORITY\SYSTEM:(F)

Paso 6 Conectar a EC2

Ahora puedes conectar con SSH usando la clave

ssh -i D:\3-tier-web-arch\nfs-key.pem ec2-user@direccion_publica_ec2

Mejor práctica Guardar claves en la carpeta .ssh

Para mayor comodidad, coloca la clave en tu carpeta .ssh y reutilízala desde ahí.

Comandos en PowerShell

mkdir $env:USERPROFILE.ssh -Force

copy D:\3-tier-web-arch\nfs-key.pem $env:USERPROFILE.ssh\nfs-key.pem

Después, crea el archivo de configuración en la ruta %USERPROFILE%\.ssh\config para definir un host corto y conectar con un simple ssh mi-ec2.

Notas operativas

Ejecuta los comandos en PowerShell como Administrador y luego conecta a la instancia EC2 desde el terminal de PowerShell en VS Code o desde PowerShell en Windows. Si gestionas múltiples claves, nómbralas de forma consistente y mantén copias de seguridad seguras. Evita compartir archivos PEM por correo o chat, y aplica cifrado en reposo cuando sea posible. Estas prácticas refuerzan la ciberseguridad en tus despliegues y pipelines.

Cómo ayuda Q2BSTUDIO

En Q2BSTUDIO impulsamos a las organizaciones con software a medida y aplicaciones a medida, integrando buenas prácticas de ciberseguridad y automatización desde el primer día. Si trabajas con AWS o Azure y quieres una arquitectura fiable, observabilidad y cumplimiento, conoce nuestros servicios cloud aws y azure para diseñar, migrar y operar cargas críticas con claves y secretos gestionados de forma segura. Además, reforzamos la protección de tus activos con auditorías, hardening de sistemas y análisis de vulnerabilidades; descubre cómo podemos ayudarte con ciberseguridad y pentesting.

Más allá de la infraestructura, nuestro equipo de especialistas en inteligencia artificial impulsa ia para empresas con modelos propios, agentes IA y soluciones de inteligencia de negocio. Conectamos tus datos y procesos para escalar decisiones y generar valor con servicios inteligencia de negocio y cuadros de mando en power bi. Integramos flujos de MLOps, monitoreo y gobierno de datos, siempre con enfoque de seguridad y cumplimiento.

Resumen ejecutivo

SSH exige seguridad estricta de la clave privada. En Windows, tradúcelo a ACL correctas tomar propiedad, eliminar herencia, quitar grupos amplios y conceder solo lectura a tu usuario. Verifica con icacls antes de conectar y guarda las claves en .ssh para simplificar. Si necesitas soporte experto para entornos EC2, automatización de despliegues, desarrollo de software a medida o proyectos de inteligencia artificial, Q2BSTUDIO es tu aliado para construir soluciones seguras, escalables y listas para producción.

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.