AWS EC2의 root 계정 활성화, 패스워드 설정, 패스워드로 로그인 활성화

기본적으로 key pair file을 이용하도록 권장하고 있지만 root 계정이 가끔 필요할 때도 있고 일단은 뭐 보안이 크게 중요하지 않은 테스트 환경이라 한 번 설정해 본다.

1. root password 설정

ubuntu@ip-172-31-24-62:~$ sudo passwd root
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

2. password 기반의 로그인을 활성화하기

ubuntu@ip-172-31-24-62:~$ sudo vi /etc/ssh/sshd_config

# Change to no to disable tunnelled clear text passwords
PasswordAuthentication no

위의 no를 yes로. 그리고 저장. 그럼 된다.

3. key pair로 로그인할 때를 위해서 root로 ubuntu user의 것을 복사.

ubuntu@ip-172-31-24-62:~$ sudo mkdir /root/.ssh
mkdir: cannot create directory ‘/root/.ssh’: File exists
ubuntu@ip-172-31-24-62:~$ sudo cp /home/ubuntu/.ssh/authorized_keys /root/.ssh/
ubuntu@ip-172-31-24-62:~$ 

이미 있어서 그냥 복사만 했음.

마지막으로 SSHd 설정을 리로드하기.

ubuntu@ip-172-31-24-62:~$ sudo reload ssh

그럼 테스트, root로 key 없이 접속해 보기.

~/Project/awskey> ssh root@54.238.207.180
root@54.238.207.180's password: 
Welcome to Ubuntu 13.10 (GNU/Linux 3.11.0-12-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Thu Oct 31 06:56:20 UTC 2013

  System load:  0.0              Processes:           66
  Usage of /:   9.5% of 7.75GB   Users logged in:     0
  Memory usage: 8%               IP address for eth0: 172.31.24.62
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

  Use Juju to deploy your cloud instances and workloads:
    https://juju.ubuntu.com/#cloud-saucy

0 packages can be updated.
0 updates are security updates.


The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

root@ip-172-31-24-62:~# 

key pair를 이용해 root로 접속하기

~/Project/awskey> ssh -i up_db_server.pem root@54.238.207.180
Welcome to Ubuntu 13.10 (GNU/Linux 3.11.0-12-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Thu Oct 31 08:10:46 UTC 2013

  System load:  0.0               Processes:           69
  Usage of /:   12.0% of 7.75GB   Users logged in:     0
  Memory usage: 26%               IP address for eth0: 172.31.24.62
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

  Use Juju to deploy your cloud instances and workloads:
    https://juju.ubuntu.com/#cloud-saucy

Last login: Thu Oct 31 08:10:47 2013 from 211.106.111.78
root@ip-172-31-24-62:~# 

댓글 2개:

  1. Thanks for providing this informative information you may also refer.
    http://www.s4techno.com/blog/2015/12/21/protect-instances-from-termination-by-auto-scaling/

    답글삭제
  2. This blog gives very important info about AWS,Thanks for sharing
    AWS Online Course

    답글삭제