1. GCP 콘솔에 접속한다.

 

2. GCP 콘솔에서 VM 인스턴스에 SSH로 접속한다.

 

3. VM 인스턴스에 접속한 후 다음 명령어를 수행한다.

sudo vi /etc/ssh/sshd_config

4. sshd_config 파일 내용 중 PasswordAuthentication no 로 설정된 부분을 yes로 변경한다.

 

5. sshd 서비스를 재기동한다.

sudo service sshd restart

6. 외부에서 접속할 VM 인스턴스의 계정을 생성한다.

sudo useradd -m  -s /bin/bash -G {groups} {new user name}

아래 예시는 users 그룹의 demouser 계정을 생성하는 명령어이다.

sudo useradd -m  -s /bin/bash -G users demouser

 

7. 계정 패스워드 설정

위에서 생성한 계정의 패스워드를 설정한다.

아래 예시는 demouser 계정의 패스워드를 설정하는 명령어이다.

sudo passwd demouser

 

8. 외부에서 해당 VM 인스턴스의 외부 IP로 접속한다. 윈도우 PC나 리눅스 서버에서 대상 VM 인스턴스에 접속한다.

ssh username@외부_IP

아래 명령어는 VM 인스턴스의 외부 IP로 위에서 생성한 계정으로 접속하는 예시이다. 아래처럼 위에서 생성한 패스워드를 입력하면 VM 인스턴스에 접속할 수 있다.

ssh demouser@35.216.99.220

demouser@35.216.99.220's password:
Linux vm-aicallbot-admin-prd-02 4.19.0-18-cloud-amd64 #1 SMP Debian 4.19.208-1 (2021-09-29) x86_64

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

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

'GCP' 카테고리의 다른 글

GCP-interconnect  (0) 2022.03.22
GCP - vpc peering 설정  (0) 2022.03.18
GCP - gcloud 설치 on linux  (0) 2022.03.13
GCP VM ssh keypair 접속  (0) 2022.03.11
GCP disk 추가  (0) 2022.02.18

+ Recent posts