Sometimes the need to log EC2 instances in different office environment, but can not copy the key back and forth to a new laptop or PC, so we can use the access codes landing EC2-Linux machines
To enable password authentication, create a password, update the / etc / ssh / sshd_config file, and then restart the SSH service.
Note: instead of using a password-based login authentication key pair has a safety hazard. Therefore, we do not recommend the use of password-based login.
In addition, the best practice is to minimize the source IP address and a secure set of rules associated with your instance to prevent SSH attacks.
First, login to the instance by key;
[centos@jump ~]$ pwd /home/centos [CentOS Jump @ ~] $ sudo - I ## is switched to the root via sudo [root@jump ~]#
set password
[root @ Jump ~] # passwd Changing password for the User root. # Set the root password New password: # Enter the password for the first time Retype new password: # Enter the password a second time passwd: all authentication tokens updated successfully.
Edit / etc / ssh / sshd_config
# vim /etc/ssh/sshd_config ... PasswordAuthentication yes # allow the use of password by no change yes PermitRootLogin yes # If you need to use the root login by no change yes, if you do not, do not move ...
Restart the SSH service
# Systemctl restart sshd # CentOS7 restart the SSH service
Service sshd restart CentOS5 # # -6 restart the SSH service
Testing using password
~ ➜ SSH the root @ 3.114 . 27.143 the root @ 3.114 . 27.143 ' S password: # password Last Login : Tue-Nov . 5 05 : 43 is : 22 is 2019 from 111.202 . 93.98 [the root Jump @ ~] #