수업 노트/aws 활용
키페어를 사용하지 않고 아이디, 패스워드로 aws ec2 ssh 이용하기
오리지날초이
2023. 11. 25. 21:41
0. ec2 에 ubuntu 설치
1. root 패스워드 생성 및 root 전환
- 사실 sudo 로 하는게 맞는데 귀찮아서..
ubuntu@ip-172-31-35-131:/$ sudo passwd root
New password:
Retype new password:
passwd: password updated successfully
ubuntu@ip-172-31-35-131:/$
ubuntu@ip-172-31-35-131:/$ su
Password:
root@ip-172-31-35-131:/#
2. ssh 설정 수정으로 패스워드 인증 허용 및 ssh 재시작
root@ip-172-31-35-131:/# vim /etc/ssh/sshd_config
PasswordAuthentication yes
root@ip-172-31-35-131:/# service ssh restart
3. 일반 유저 생성
- adduser 가 아닌 useradd 로 생성하면 홈디렉토리를 안 만들어준다.
- adduser 로 만들자
root@ip-172-31-35-131:/home# adduser level1
Adding user `level1' ...
Adding new group `level1' (1001) ...
Adding new user `level1' (1001) with group `level1' ...
Creating home directory `/home/level1' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for level1
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
root@ip-172-31-35-131:/home#
root@ip-172-31-35-131:/home# adduser level2
Adding user `level2' ...
Adding new group `level2' (1002) ...
Adding new user `level2' (1002) with group `level2' ...
Creating home directory `/home/level2' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for level2
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
root@ip-172-31-35-131:/home#
root@ip-172-31-35-131:/home#
root@ip-172-31-35-131:/home# ls -al
total 20
drwxr-xr-x 5 root root 4096 Nov 25 12:34 .
drwxr-xr-x 19 root root 4096 Nov 25 12:23 ..
drwxr-x--- 2 level1 level1 4096 Nov 25 12:34 level1
drwxr-x--- 2 level2 level2 4096 Nov 25 12:33 level2
drwxr-x--- 4 ubuntu ubuntu 4096 Nov 25 12:25 ubuntu
root@ip-172-31-35-131:/home# useradd level3
root@ip-172-31-35-131:/home# ls -al
total 20
drwxr-xr-x 5 root root 4096 Nov 25 12:34 .
drwxr-xr-x 19 root root 4096 Nov 25 12:23 ..
drwxr-x--- 2 level1 level1 4096 Nov 25 12:34 level1
drwxr-x--- 2 level2 level2 4096 Nov 25 12:33 level2
drwxr-x--- 4 ubuntu ubuntu 4096 Nov 25 12:25 ubuntu
root@ip-172-31-35-131:/home# userdel level3
root@ip-172-31-35-131:/home#
4. 키페어 없이 id, pw 만으로 level1 으로 ssh 접속확인
Microsoft Windows [Version 10.0.19045.3693]
(c) Microsoft Corporation. All rights reserved.
C:\Users\USER>ssh level1@ec2-3-39-232-188.ap-northeast-2.compute.amazonaws.com
level1@ec2-3-39-232-188.ap-northeast-2.compute.amazonaws.com's password:
Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 6.2.0-1012-aws x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Sat Nov 25 12:38:12 UTC 2023
System load: 0.0 Processes: 104
Usage of /: 20.8% of 7.57GB Users logged in: 1
Memory usage: 21% IPv4 address for eth0: 172.31.35.131
Swap usage: 0%
Expanded Security Maintenance for Applications is not enabled.
0 updates can be applied immediately.
Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
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.
level1@ip-172-31-35-131:~$
5. ec2 인스턴스를 전통적인 방식으로 활용할 수 있게 되었다.
이걸로 짬짬이 linux training 코스 만들어도 될 듯.
728x90
반응형