Connect to Amazon EC2 with SSH (Ubuntu)

Article content

When connecting to SSH from Ubuntu in AWS practice, it took time to investigate various things to avoid the following error, so I wrote the command as a reminder. I struggled because I didn't know much about Linux commands.

Permission denied (publickey,gssapi-keyex,gssapi-with-mic)


If Ubuntu doesn't have an SSH client, install it.

 $ sudo apt-get install openssh-client 

Move the key to the folder under the user name.

 $mv key name.pem /home/User name/.ssh 

Permission setting

 $chmod 400 key name.pem 

SSH connection

$ ssh -i key name.pem ec2-user@[IP address or DNS name]


In my case, I made a mistake in writing the user name ec2-user, or placed the key file in an appropriate location, and the error could not be resolved and I could not move forward easily. Please refer to those who are starting from now.

Recommended Posts

Connect to Amazon EC2 with SSH (Ubuntu)
Connect to DB with Java
Connect to MySQL 8 with Java
Connect to oracle with eclipse!
Ssh connect from container to git with VSCode Remote Container
Deploy to EC2 with CircleCi + Capistrano
Connect to Rails server with iPhone
ubuntu ssh
I want to connect SONY headphones WH-1000XM4 with LDAC on ubuntu 20.04! !!
Install Ubuntu Server 20.04 in VirtualBox on Mac and connect with SSH
Introduced vscode with apt to docker: ubuntu
Sample to start Ubuntu with Deployment with client-go
Serially connect to Ubuntu on Raspberry Pi
How to SSH into Ubuntu from a terminal with public key authentication
Rip a CD to MP3 with Ubuntu 18.04 LTS
How to use nfs protocol version 2 with ubuntu 18.04
Burn files to CD / DVD with Ubuntu 18.04 LTS
Create a private key / public key in CentOS8.2 and connect to SSH with VS Code
VNC connection to Ubuntu Desktop with Mac screen sharing.
How to connect MySQL / MariaDB + HikariCP with Liferay 7 / DXP
I started MySQL 5.7 with docker-compose and tried to connect
How to install NVIDIA driver on Ubuntu ssh destination
Connect with port forwarding with SSH and send and receive files
How to use RealSense with ubuntu 20.04 and ROS Noetic
I want to redirect sound from Ubuntu with xrdp
What to do if you enable UFW on Ubuntu VM on GCP and you can't connect to SSH
[Java] Connect to MySQL
Install Gradle with ubuntu16.04
[AWS] Link memory usage of Ubuntu EC2 instance to CloudWatch
Connect to multiple MySQL instances with SSL enabled in JDBC
Connect to database with spring boot + spring jpa and CRUD operation
I tried to automate LibreOffice Calc with Ruby + PyCall.rb (Ubuntu 18.04)
Build mate desktop environment on ec2 with terraform (Ubuntu 20.04LTS)
Try setting up Talend Open Studio on Amazon EC2 (ubuntu)
I can no longer connect to a VM with a Docker container that can be connected via SSH
What to do if an SSH key authentication error occurs during automatic deployment to EC2 with Capistrano
Let's create a Docker container that can connect to CentOS 8 with the minimum configuration by SSH