Change SSH key EC2 instance (Ubuntu)

Subscribers:
4,970
Published on ● Video Link: https://www.youtube.com/watch?v=woR__-MaKQw



Duration: 0:00
67 views
1


By default, when you login to server, you authenticate with username+private key.

In this video, i will show you how to change private key (SSH key) EC2 instance (OS ubuntu).

Steps:
cd /home/ubuntu/.ssh
mv authorized_keys authorized_keys.old
ssh-keygen -m PEM -t rsa -b 4096 -C "my-new-key"
mv /root/.ssh/id_rsa.pub /home/ubuntu/.ssh/authorized_keys
cd /home/ubuntu/.ssh
chown ubuntu:ubuntu authorized_keys
chmod 600 authorized_keys


save your /root/.ssh/id_rsa to your local computer as pem / ppk, for example my-new-key.pem
then login to server using my-new-key.pem
ssh -i my-new-key.pem ubuntu@your-ec2-instance-ip




Other Videos By Ambar Hasbiyatmoko


2025-04-22How to set SSH idle timeout on Ubuntu 22.04
2025-04-11Codeigniter3-The server requested authentication method unknown to the client caching sha2 password
2025-03-26How to increase .vdi size in virtualbox 7
2025-03-23How to fix MySQL SHELL FOR VSCODE - Create New DB Connection button cannot be clicked
2024-12-31How to solve EFS issues (AWS) - unknown filesystem type 'efs', cargo not found and mount attempt
2024-12-28How to solve composer - No composer.json in current directory when installing guzzlehttp
2024-12-12How to fix error installing openswan on Amazon Linux 2023 - Error: Unable to find a match: openswan
2024-12-07Change SSH key EC2 instance (Ubuntu)
2024-11-24Fixing Airbyte - You appear to have deployed over HTTP Make sure your have disabled secure cookies
2024-11-15How to fix airbyte - Failure in source. Saved offset no longer present on the server
2024-11-14How to solve wordpress - The update cannot be installed because some files could not be copied
2024-11-08How to solve kubernetes dashboard not showing CPU and RAM usage
2024-10-26How to uninstall kubernetes dashboard using helm chart
2024-10-26How to solve Kubernetes - configuration file is group-readable. This is insecure. Location: config
2024-10-24How to solve kubernetes: kubernetes.io/ingress.class is deprecated, please use spec.ingressClassName
2024-10-13How to solve error importing .sql file - You have an error in your SQL syntax; SQL SECURITY DEFINER
2024-09-03How to solve vault error - gosnowflake DBUS_SESSION_BUS_ADDRESS envvars looks to be not set
2024-08-10How to solve user in samba active directory (EC2 AWS) - Cannot connect to the IP RDP Server
2024-08-04How to solve samba active directory (ad-dc) on ubuntu - chgrp invalid group: domain users
2024-08-01How to solve samba join active directory - Our netbios name can be at most 15 chars long
2024-07-27How to solve resolv.conf in ubuntu - failed removing file /etc/resolv.conf Operation not permitted