有効なルート/ユーザーパスワードがEC2で機能しない

有効なルート/ユーザーパスワードがEC2で機能しない

アップデートを使用した後にアカウントのパスワードを入力しようとすると、認証は失敗します。まあ。私の認証は壊れていますが、他のすべては正常に動作します。

これらのアップデートは主に既存のAWSソースで提供されていますが、外部ソースも含まれていました。何が起こっているのか、問題を解決し、変更をロールバックする方法があるかどうかを知りたいです。

それでもsshを使用して(pemファイルを介して)AWS EC2インスタンスにログインできますが、これは私ができることです。古いパスワードを使用してssh root@ipaddressを介してログインすることはできません。それに変えるセキュリティ資格情報ページ - >パスワード役に立ちません。似たようなものが見つかりました。質問

私のもの/var/log/secure

sshd[1184]: Server listening on 0.0.0.0 port 22.
sshd[1184]: Server listening on :: port 22.
runuser: pam_unix(runuser:session): session opened for user mongod by (uid=0)
runuser: pam_unix(runuser:session): session closed for user mongod
sshd[1576]: Accepted publickey for ec2-user from xxx.xxx.xxx.xxx port xxxxx ssh2: RSA xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
sshd[1576]: pam_unix(sshd:session): session opened for user ec2-user by (uid=0)
sudo: pam_unix(sudo:auth): authentication failure; logname=ec2-user uid=500 euid=0 tty=/dev/pts/0 ruser=ec2-user rhost=  user=ec2-user
sudo: ec2-user : user NOT in sudoers ; TTY=pts/0 ; PWD=/home/ec2-user ; USER=root ; COMMAND=/bin/su -
su: pam_unix(su:auth): authentication failure; logname=ec2-user uid=500 euid=0 tty=pts/0 ruser=ec2-user rhost=  user=root
sudo: pam_unix(sudo:auth): authentication failure; logname=ec2-user uid=500 euid=0 tty=/dev/pts/0 ruser=ec2-user rhost=  user=ec2-user
sudo: ec2-user : user NOT in sudoers ; TTY=pts/0 ; PWD=/home/ec2-user ; USER=root ; COMMAND=/bin/ls
sshd[1184]: Received signal 15; terminating.
sshd[1576]: pam_unix(sshd:session): session closed for user c2-user

私のもの/etc/ssh/sshd_config

#   $OpenBSD: ssh_config,v 1.28 2013/09/16 11:35:43 sthen Exp $

# This is the ssh client system-wide configuration file.  See
# ssh_config(5) for more information.  This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.

# Configuration data is parsed as follows:
#  1. command line options
#  2. user-specific file
#  3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.

# Site-wide defaults for some commonly used options.  For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.

# Host *
#   ForwardAgent no
#   ForwardX11 no
#   RhostsRSAAuthentication no
#   RSAAuthentication yes
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   GSSAPIKeyExchange no
#   GSSAPITrustDNS no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/identity
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   Port 22
#   Protocol 2,1
#   Cipher 3des
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,[email protected],hmac-ripemd160
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
#   ProxyCommand ssh -q -W %h:%p gateway.example.com
#   RekeyLimit 1G 1h
#
# Uncomment this if you want to use .local domain
# Host *.local
#   CheckHostIP no

Host *
    GSSAPIAuthentication yes
# If this option is set to yes then remote X11 clients will have full access
# to the original X11 display. As virtually no X11 client supports the untrusted
# mode correctly we set this to yes.
    ForwardX11Trusted yes
# Send locale-related environment variables
    SendEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
    SendEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
    SendEnv LC_IDENTIFICATION LC_ALL LANGUAGE
    SendEnv XMODIFIERS
# Don't show actual hostnames in .ssh/known_hosts
    HashKnownHosts yes

呼び出しの結果ls -l /etc/passwd /etc/shadow /etc/sudoersは次のとおりです。

-rw-r--r-- 1 root  root 1402 Oct  7 10:58 /etc/passwd
---------- 1 root  root  838 Oct  7 10:58 /etc/shadow
-r--r----- 1 root wheel 2299 Oct  7 10:58 /etc/sudoers

私のOSの設定:

NAME="Amazon Linux AMI"
VERSION="2015.09"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2015.09"
PRETTY_NAME="Amazon Linux AMI 2015.09"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2015.09:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
Amazon Linux AMI release 2015.09

コマンドaws ec2 get-password-data --instance-id XXXXXXXXXXの結果(Windows以外のインスタンスに適用されるかどうかわからない):

{
    "InstanceId": "XXXXXXXXXX", 
    "Timestamp": "2015-10-12T21:02:51.000Z", 
    "PasswordData": ""
}

ベストアンサー1

最後に、新しいインスタンスを起動し、既存のインスタンスからボリュームをマウントして、rootアカウントへの失われたアクセス権を回復しました。

sudo mount /dev/sdf /mnt/my-data

sudo vi /mnt/my-data/etc/ssh/sshd_config次の変更後:

PermitRootLogin yes
#PermitRootLogin forced-commands-only

その後、ボリュームを元のインスタンスに戻し、SSH経由でrootとしてログインしました。

sudo ssh -i /key.pem [email protected]

rootとしてログインした状態で、passwd username各ユーザーのパスワード変更を実行します。

おすすめ記事