상세 컨텐츠

본문 제목

AWS EC2 ssh root 접속하기

Ops/Cloud

by 크리두 2019. 12. 4. 12:06

본문

반응형

AWS에 대한 자세한 내용은 다른 글에서 다루도록 하겠습니다.

 

현재 많은 백엔드 엔지니어 또는 스타트업 개발자들이 AWS 생태계에서 개발을 많이 하고 있는 추세입니다.

EC2를 올리고 퍼블릭 키를 통해 보안 접속을 하는 형태로 이용중이지만 팀에서 사용하기엔 번거로움이 있는 편이죠.

그래서 공개키 없이 접속을 할 경우도 발생하여 정리합니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
Port 2233
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
 
HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
 
# Ciphers and keying
#RekeyLimit default none
 
# Logging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO
 
# Authentication:
 
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
 
#PubkeyAuthentication yes
 
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
 
#AuthorizedPrincipalsFile none
 
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
 
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
 
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
#PermitEmptyPasswords no
#PasswordAuthentication no
 
# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter

EC2로 생성된 인스턴스는 기본적으로 PasswordAuthentication 항목이 no로 설정되어 있다. 이 부분을 yes로 변경하거나 주석처리 해주면 공개키 파일을 사용하지 않고 외부에서 ID/Password를 사용해 ssh 접속이 가능하다.

 

SELINUX 설정

SELINUX를 사용하고 있다면 다음과 같이 명령하여 2233 포트를 사용할 수 있게 만듭니다.

semanage port -a -t ssh_port_t -p tcp 2233

방화벽 설정

방화벽에 2233 포트를 추가합니다.

firewall-cmd --permanent --zone=public --add-port=2233/tcp

방화벽을 다시 로드합니다.

firewall-cmd --reload

테스트

현재 접속은 그대로 두고, SSH 클라이언트 프로그램을 새로 열여 변경한 포트로 접속해봅니다.

Log

참고로, SSH 접속과 관련된 로그는

/var/log/secure

에 있습니다.

반응형

'Ops > Cloud' 카테고리의 다른 글

AKS Best Practice - Pod 보안  (0) 2024.02.22
AWS Subnet 생성 및 라우팅 퍼블릭 설정  (0) 2020.08.15
AWS CLI 설치 및 VPC/Subnet 생성  (0) 2020.08.15

관련글 더보기

댓글 영역