What to do if you lose your EC2 key pair

If you lose your EC2 key pair, you can register another key pair with your existing instance. You don't have to create a new instance.

The procedure for linux / MacOS is shown as an example.

Create a new key pair

Creating a new key pair is not mandatory. Skip if you want to use another existing key pair.

  $ mv xxxxx.pem ~/.ssh/
  $ chmod 400 ~/.ssh/xxxxx.pem

For Windows

Create a public key

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQClKsfkNkuSevGj3eYhCe53pcjqP3maAhDFcvBS7O6V
hz2ItxCih+PnDSUaw+WNQn/mZphTk/a/gU8jEzoOWbkM4yxyb/wB96xbiFveSFJuOp/d6RJhJOI0iBXr
lsLnBItntckiJ7FbtxJMXLvvwJryDUilBMTjYtwB+QhYXUMOzce5Pjz5/i8SeJtjnV3iAoG/cQk+0FzZ
qaeJAAHco+CY/5WrUBkrHmFJr6HcXkvJdWPkYQS3xqC0+FmUZofz221CBt5IMucxXPkX4rWi+z7wB3Rb
BQoQzd8v7yeb7OzlPnWOyN0qFU0XA246RA8QFYiCNYwI3f05p6KLxEXAMPLE

For Windows

Modify user data for EC2 instances

Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0

--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"

#cloud-config
cloud_final_modules:
- [users-groups, once]
users:
  - name: username
    ssh-authorized-keys: 
    - PublicKeypair

Modify * ** users.name ** and ** PublicKeypair ** and click "Save"

reference

[How do I connect to my Amazon EC2 instance if I lose my SSH key pair after the first boot?](Https://aws.amazon.com/jp/premiumsupport/knowledge-center/user-data-replace -key-pair-ec2 /)

Recommended Posts

What to do if you lose your EC2 key pair
What to do if you can't build your project with Maven
What to do if you can't pipenv shell
What to do if you forget your login password on Manjaro Linux
What to do if you can't pip install mysqlclient
No module named What to do if you get'libs.resources'
ModuleNotFoundError: No module What to do if you get'tensorflow.contrib'
What to do if you get an "unknown service" error from your gRPC server
What to do if yum breaks
What to do if you are addicted to Windows character code
What to do if you get "coverage unknown" in Coveralls
What to do if you can't sort files with subscripts
What to do if you can't log in as root
What to do if you can't use WiFi on Linux
What to do if you can't install pyaudio with pip #Python
What to do if you get a minus zero in Python
What to do if you get a UnicodeDecodeError with pip install
What to do if the inode is exhausted on EC2 Linux
What to do if you can't use the trash in Lubuntu 18.04.
Let's summarize what you want to do.
CommandNotFoundError: Your shell has not been properly configured to use What to do if you get'conda activate'
What to do if you couldn't send an email to Yahoo with Python.
What to do if you can't use scikit grid search in Python
What to do if your disk runs out due to MySQL binary logs
What to do if you get lost in file reference with FileNotFoundError
What to do if you get angry in TensorFlow v2 without attribute'app'
What to do if you get stuck during Anaconda installation on Linux
What to do if you get a TypeError with numpy min, max
What to do if you get an error when trying to load mnist
What to do if you can't install with pip in babun environment
What to do if you get Could not fetch URL 443 with pip
What to do if fprintd requires a password when registering your fingerprint
What to do if you get an error when installing Dlib (Ubuntu)
What to do if pipreqs results in UnicodeDecodeError
What to do if mod_fcgid cannot resolve UnicodeEncodeError
What to do if rails s doesn't work
What to do if you should have set an ssh key but are prompted for a password
What to do if pip cannot be installed
What to do if you get a Permission denied (public key) error when trying to pull on Github
What to do if atom autocomplete-python doesn't work
What to do if Docker-sync suddenly stops working
What to do if "amazon-linux-extras" → "No module named amazon_linux_extras"
What to do if you get angry with swapon failed: Operation not permitted
What to do if you get an error when installing python with pyenv
What to do if you get "Python not configured." Using PyDev in Eclipse
What to do if pip install fails in Xcode 5.1
What to do if SciPy installation fails on CentOS
Links to do what you want with Sublime Text
What to do if a UnicodeDecodeError occurs in pip
What to do if pip install fails to install dependent libraries
What to do if sys / cdefs.h does not exist
What to do if pyenv is not enabled (zsh)
What to do when you can't bind CaboCha to Python
What to do if ubuntu says your password is too short to change [passwd command] [ubuntu]
What to do if your Jupyter Notebook for beginners asks for a password or token
What to do if you get an OpenSSL error when installing Python 2 with pyenv
What to do if the Microsoft Store opens even if you run python on Windows
What to do if you get `No kernel for language python found` in Hydrogen
What to do if you get a memory error when converting from PySparkDataFrame to PandasDataFrame
What to do if you get "(35,'SSL connect error')" in pycurl (one of them)
What to do if you get an error when importing matplotlib in Python (Mac)