[Amazon Linux 2] Change from public key authentication to password authentication

Contents

Change the connection method to EC2 from public key authentication to password authentication

** Similar articles ** Learn sshd_config and authorized_keys (for Amazon Linux 2)

procedure

Make an SSH connection to the target EC2 and switch the user to ** root **.

Back up sshd_config

Be sure to make a backup before changing the settings.

# cd /etc/ssh/
# pwd
/etc/ssh

# ls -l
total 608
...
-rw-r--r-- 1 root root       2276 Mar 15 12:25 ssh_config
-rw------- 1 root root       3977 Mar 15 12:04 sshd_config
...

# cp -p sshd_config sshd_config_yyyymmdd
# ls -l
total 608
...
-rw-r--r-- 1 root root       2276 Mar 15 12:25 ssh_config
-rw------- 1 root root       3977 Mar 15 12:04 sshd_config
-rw------- 1 root root       3977 Mar 15 12:04 sshd_config_yyyymmdd
...

sshd_config setting change

We will change the settings of sshd_config. (Change before) #PubkeyAuthentication yes PasswordAuthentication no

(After change) PubkeyAuthentication no PasswordAuthentication yes

# vi sshd_config
# cat sshd_config | grep PubkeyAuthentication
#PubkeyAuthentication yes
PubkeyAuthentication no

# cat sshd_config | grep PasswordAuthentication
PasswordAuthentication yes
#PasswordAuthentication no

# systemctl restart sshd.service

Use the vi command to change the settings, and use cat + grep to confirm that the changes have been made without any problems. Then restart sshd.service with the systemctl command.

Connection confirmation by password authentication

Use Teraterm to check if you can log in with password authentication. At that time, please keep the current connection.

Enter the IP address and press OK. ss_000.JPG

Enter your username and password and select ** Use Brain Password (L) ** to connect. ss_001.JPG

I was able to connect. ss_002.JPG

the end

Now you can change to password authentication. I was able to do it, but password authentication is not so good, so let's restore it.

# cp -p  sshd_config_yyyymmdd sshd_config
# systemctl restart sshd.service

Recommended Posts

[Amazon Linux 2] Change from public key authentication to password authentication
[Linux setting series] How to set public key authentication / ssh-keygen / ssh key / authorized_keys
How to set up public key authentication in ssh
Stop SSH password authentication and switch to key authentication completely
Change the Amazon Linux locale to Japan using Ansible's lineinfile
Use ssh with private key public key authentication. Connect from wan.
Log in to Raspberry PI with ssh without password (key authentication)
A memorandum to change to Manjaro Linux
How to install wkhtmltopdf (Amazon Linux2)
Introducing Amplify to Amazon Linux 2 AMI
Did not change from Python 2 to 3
Data integration from Python app on Linux to Amazon Redshift with ODBC
Change AWS EC2 instance from t2 to t3
Ssh login with public key authentication quickly
[Linux] Flow from power-on to PC startup
[Refactoring Catalog] Change from reference to value
How to update php on Amazon linux 2
Upgraded mysql on Cloud9 (Amazon Linux) (5.5 to 5,7)
How to install Anisble on Amazon Linux 2
How to operate Linux from the console
[SSH] About public key authentication and EC2
Introducing Docker Engine to Linux From Scratch
Change the Key of Object on S3 from normal date format to Hive format
[Linux] For super beginners Tips when public key authentication settings do not work
Easy script migration from CentOS to Oracle Linux
Change the decimal point of logging from, to.
How to operate Linux from the outside Procedure
How to handle Linux commands well from Python
Added firewalld to Amazon Linux 2 (IP address restrictions)
Jupyter Notebook Settings-How to use (EC2 Amazon Linux 2)
Back up from QNAP to Linux with rsync