Ossian Story
article thumbnail

[GCP] Linux Instance Root로 SSH 접속하기


Prologue


GCP에서 Linux Instance를 생성하여 SSH를 접속하면 GCP 계정에 따른 User 계정이 생성됩니다.

보안을 위하여 "sudo"를 사용하여 Management를 할 수 있지만 상황에 따라 Root 계정을 사용해야 할 일들이 발생됩니다.


아래의 포스팅을 통해 GCP Linux Instance에서 Root 계정을 직접적으로 사용하는 두가지 방법에 대해 알아보겠습니다.


OS 기준은 GCP의 CentOS 7 Instance 기준으로 작성되었습니다.



Root 계정 사용 - 1


GCP에서 CentOS 7 Instance를 생성 후 GCP에서 제공하는 SSH로 접속합니다.



아래와 같이 "sudo passwd"를 통해 root 패스워드를 설정 후 사용할 수 있습니다.

[jake_nam88@root-test ~]$ sudo passwd
 
Changing password for user root.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.
[jake_nam88@root-test ~]$ su
Password: 
 
[root@root-test jake_nam88]




Root 계정 사용 - 2


위와 같이 root 계정에 대한 패스워드를 설정하여도 Putty와 같은 SSH Tool을 사용하여 접속하려한다면 오류가 발생됩니다.

SSH를 사용하여 root에 직접적으로 로그인하고자 한다면 아래와 같이 PermitRootLogin과 PasswordAuthentication의 설정을 'no > yes'로 SSH의 설정을 변경합니다.


[root@root-test jake_nam88]# vi /etc/ssh/sshd_config
 
-----------------------------------------------------
 
# Authentication:
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
 
-----------------------------------------------------
 
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes
# Change to no to disable s/key passwords
 
-----------------------------------------------------





profile

Ossian Story

@ossians