본문 바로가기
서버/리눅스 서버

오라클 프리티어 계정 생성 및 인스턴스 생성하기

by ㅋㅋ잠자 2020. 4. 23.
반응형

안녕하세요? 간결하게 오라클 프리티어 계정 생성 및 머신 생성까지 가보겠습니다.


US : East 리전

KO : Korea 리전





1. 계정 생성


아래의 주소에서 가입을 하시길바랍니다.


이 글은 국내를 기반으로 하고 있기 때문에 미국 주소등을 고려하지 않습니다.


https://www.oracle.com/kr/cloud/free/


중간에 주소 및 전화번호 인증 및 카드등록 까지 하게 되는데요.


1달러를 한번 빼보는 것 같습니다.


(환율 살벌하네요.)






2. 로그인 하기


리뷰잉 중이라고 메일이 날아옵니다. 리뷰가 끝나지 않으면 로그인을 못하는 거 같네요.



잠시 기다려 보겠습니다.





3. 카드 관련 회원 가입 문제


오라클 클라우드의 경우 카드를 많이 가리는 것 같습니다. 


상기와 같이 리뷰잉 중이라고 나오고, 실제로 카드 결제가 이루어졌지만 통과가 안되는 부분이 있습니다.


실제로 가입할 때 당시에 성공이 되지 않으면 영원히 성공을 하지 못합니다. 그래서 몇가지 규칙을 알아낸 것이..


체크카드가 아닌 신용카드로 해야하며, 현대카드 / 아멕스 카드 등 이름있는 카드로 결제를 해야 성공이 되는 것 같습니다. 


우리V체크카드 / 카카오페이 무지 체크카드 (신한) / 네이버 페이 삼성카드(신용) / 카드의 정석 DA(체크) 모두 가입에 실패하였습니다. 한가지, 현대카드 사원증으로만 가입이 되었네요.



초기에는 국내 아이디 / 해외 아이디 이렇게 가입을 하려고 했는데 국내 밖에 성공을 하지 못해서 아쉽게도 못하게 되었습니다.


국내 클라우드의 경우 자리가 없어서 VM 인스턴스가 생성이 안되는 등의 문제가 있었는데요. 오늘 에디님께서 알려주셔서 생성을 하게 되었고 이 가이드를 이어서 작성할 수 있게 되었습니다.





4. 초기 콘솔 알아보기


초기에 로그인을 하고 나면 아래와 같이 UI가 나옵니다.


인스턴스 / DB 등 생성을 할 수 있는 간단한 메뉴와 상기와 우측에 크레딧이 얼마 남았다는 정보가 나옵니다.


이외 상세 부분은 오라클 클라우드를 상세하게 구축할 목적이 아니기 때문에 간단하게만 보고 넘어 가겠습니다.



프리티어 정보는 아래와 같습니다.



저희가 관심있는 부분만 생각을 하면 


일단 스토리지가 100GB / Compute 인스턴스가 2개


그럼, 그럼 인스턴스를 총 2개 생성이 가능하고, 인스턴스의 사양은 2vCore / 1GB RAM / 50GB 용량을 가진다고 보시면 됩니다.





5. 인스턴스를 생성


인스턴스를 생성할 때 프리티어 가능한 부분에 대해서 아래와 같이 가능한 부분이 나옵니다.



리눅스 운영체제는 대부분 무료이며, Micro 사양으로 선택하면 항상 무료가 가능합니다.



SSH 키의 경우 개인키 인증을 통해 인증하는 방식으로 지금 추가해도 되고 나중에 추가해도 됩니다.


일단 그냥 넘어가겠습니다.


키를 여기서 무조껀 넣어 주시고 생성하시길 바랍니다. 추후 키 변동이 생길 경우 접근이 되지 않습니다.


하기 클라우드 쉘을 통한 로그인 방법을 보시고 키를 생성하실 때 넣어주시길 바랍니다.



생성을 하면 아래와 같이 두개의 인스턴스가 나옵니다.


간혹가다가 인스턴스 목록이 나오지 않는 부분이 있는데 하기 태그를 확인해서 선택해 주시면 됩니다.



목록범위가 지정한 구획으로 선택이 되어있는지 확인 후, 인스턴스 목록을 보시면 목록이 나올 것입니다.


일단 2개 까지 무료이기 때문에 2개를 생성하고 넘어갑니다.





6. 인스턴스 ssh 연결


본래 개인키 기반으로 로그인을 하게 되어 있어서, 일단은 초기에는 SSH 키로 로그인을 해야합니다.


윈도우 환경에서는 그 환경을 만들기가 어렵기 때문에 아래와 같이 cloudshell 을 이용하여 초기 로그인을 해보겠습니다.



우측 상단 쉘 모양을 누르면 아래에 클라우드 쉘이 열립니다.


시간이 조금 걸리기 때문에 조금 기다리셔야 합니다.



자 그럼 여기서 키를 하나 생성하고 등록해 보겠습니다.


djj9405@cloudshell:~ (ap-seoul-1)$ ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/djj9405/.ssh/id_rsa): 

Created directory '/home/djj9405/.ssh'.

Enter passphrase (empty for no passphrase): 

Enter same passphrase again: 

Your identification has been saved in /home/djj9405/.ssh/id_rsa.

Your public key has been saved in /home/djj9405/.ssh/id_rsa.pub.

The key fingerprint is:

SHA256:Ku+DtoIbfavnwt6RPgpRAXW/juwRypz/DxCAGLUUKjM djj9405@a575b8431525

The key's randomart image is:

+---[RSA 2048]----+

|+*B..            |

|oo = .           |

|E o . .          |

|.+   . .         |

|.   o . S        |

| = + * .         |

|oo* O.+          |

|.o+*=*..         |

|.o+OO=+o.        |

+----[SHA256]-----+

djj9405@cloudshell:~ (ap-seoul-1)$


다음으로 생성된 키를 cat 하여 확인해보겠습니다.


djj9405@cloudshell:~ (ap-seoul-1)$ cat ~/.ssh/id_rsa.pub 

ssh-rsa AuDd9klkr98/tJIZXFYTpIgMkhpRTSKcsMsKRHaBfhgAuDd9klkr98/tJIZXFYTpIgMkhpRTSKcsMsKRHaBfhgAuDd9klkr98/tJIZXFYTpIgMkhpRTSKcsMsKRHaBfhgAuDd9klkr98/tJIZXFYTpIgMkhpRTSKcsMsKRHaBfhgAuDd9klkr98/tJIZXFYTpIgMkhpRTSKcsMsKRHaBfhgAuDd9klkr98/tJIZXFYTpIgMkhpRTSKcsMsKRHaBfhgAuDd9klkr98/tJIZXFYTpIgMkhpRTSKcsMsKRHaBfhgAuDd9klkr98/tJIZXFYTpIgMkhpRTSKcsMsKRHaBfhg/Q3GxOIe8PfMtZnEpj315Gmtmy1sLr+2ShxA9+cB djj9405@a575b8431525

djj9405@cloudshell:~ (ap-seoul-1)$


상기 ssh-rsa ~ djj9405@a57~ 까지가 키 입니다.


원하는 인스턴스로 가서 키 등록을 해줍니다.


콘솔 화면에서 콘솔 접속 메뉴를 클릭하고 콘솔 접속 생성을 누릅니다.



그리고 SSH 키 붙여넣기를 통해 키를 넣습니다.



정상적으로 활성으로 되어 있는지 체크합니다.



다음으로, 클라우드 쉘을 통해서 접근을 해보겠습니다.


아이피는 클라우드 콘솔 화면에서 확인이 가능합니다.



djj9405@cloudshell:~ (ap-seoul-1)$ ssh ubuntu@140.238.3.212

Permission denied (publickey).


아무리 해도 접근이 되지 않았습니다.


미국 EAST 리전의 경우 추후에 키를 등록하여도 정상적으로 로그인이 가능했으나, 한국 리전의 경우 접근 자체가 되지 않네요.


그래서 지우고 다시 생성할 때, 키를 넣어 주었습니다.


djj9405@cloudshell:~ (ap-seoul-1)$ ssh ubuntu@140.238.19.22

The authenticity of host '140.238.19.22 (140.238.19.22)' can't be established.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '140.238.19.22' (ECDSA) to the list of known hosts.

Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 5.0.0-1014-oracle x86_64)


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

 * Management:     https://landscape.canonical.com

 * Support:        https://ubuntu.com/advantage

This system has been minimized by removing packages and content that are

not required on a system that users do not log into.


To restore this content, you can run the 'unminimize' command.


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.


To run a command as administrator (user "root"), use "sudo <command>".

See "man sudo_root" for details.


ubuntu@cloud1-instance-20200502-1107:~$


흠, 결국에 인스턴스를 삭제하고 다시 생성하는 불상사가 생겼습니다.


꼭 VM 을 생성하실 때 SSH 키를 넣어 주시길 바랍니다.






7. SSH 패스워드 인증 설정


일단 /etc/ssh/sshd_config 을 건들이기 전에 root 계정과 현 ubuntu 계정의 비밀번호를 수정합니다.


ubuntu@cloud1-instance-20200502-1107:~$ sudo passwd ubuntu

Enter new UNIX password: 

Retype new UNIX password: 

passwd: password updated successfully

ubuntu@cloud1-instance-20200502-1107:~$ sudo passwd root

Enter new UNIX password: 

Retype new UNIX password: 

passwd: password updated successfully


다음으로, sshd 설정을 해야 하는데 nano 나 vim 이 설치되어 있지 않아서 apt update 후 설치를 해야합니다.


ubuntu@cloud1-instance-20200502-1107:~$ sudo nano /etc/ssh/sshd_config 

sudo: nano: command not found

ubuntu@cloud1-instance-20200502-1107:~$ sudo vi /etc/ssh/sshd_config 

sudo: vi: command not found


ubuntu@cloud1-instance-20200502-1107:~$ sudo apt update && sudo apt install vim nano 

Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]

Get:2 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic InRelease [242 kB]

Get:3 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [707 kB]

Get:4 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]

Get:5 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]

Get:6 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1019 kB]

Get:7 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [224 kB]

Get:8 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [40.3 kB]

Get:9 http://security.ubuntu.com/ubuntu bionic-security/restricted Translation-en [10.2 kB]    

Get:10 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [660 kB]       

Get:11 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en [219 kB]                                                                                                                  

Get:12 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [7392 B]                                                                                                                

Get:13 http://security.ubuntu.com/ubuntu bionic-security/multiverse Translation-en [2788 B]                                                                                                                

Get:14 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic/main Translation-en [516 kB]                                                                                                         

Get:15 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [9184 B]                                                                                                   

Get:16 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic/restricted Translation-en [3584 B]                                                                                                   

Get:17 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [8570 kB]                                                                                                    

Get:18 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic/universe Translation-en [4941 kB]                                                                                                    

Get:19 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [151 kB]                                                                                                   

Get:20 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic/multiverse Translation-en [108 kB]                                                                                                   

Get:21 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [932 kB]                                                                                                 

Get:22 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [318 kB]                                                                                                 

Get:23 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [50.2 kB]                                                                                          

Get:24 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-updates/restricted Translation-en [12.6 kB]                                                                                          

Get:25 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1068 kB]                                                                                            

Get:26 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [332 kB]                                                                                             

Get:27 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [15.5 kB]                                                                                          

Get:28 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-updates/multiverse Translation-en [6352 B]                                                                                           

Get:29 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages [7516 B]                                                                                               

Get:30 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-backports/main Translation-en [4764 B]                                                                                               

Get:31 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [7484 B]                                                                                           

Get:32 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-backports/universe Translation-en [4436 B]                                                                                           

Fetched 20.4 MB in 25s (803 kB/s)                                                                                                                                                                          

Reading package lists... Done

Building dependency tree       

Reading state information... Done

13 packages can be upgraded. Run 'apt list --upgradable' to see them.

Reading package lists... Done

Building dependency tree       

Reading state information... Done

The following package was automatically installed and is no longer required:

  grub-pc-bin

Use 'sudo apt autoremove' to remove it.

The following additional packages will be installed:

  libpython3.6 libpython3.6-minimal libpython3.6-stdlib python3.6 python3.6-minimal vim-common vim-runtime

Suggested packages:

  spell python3.6-venv python3.6-doc binutils binfmt-support ctags vim-doc vim-scripts

The following NEW packages will be installed:

  libpython3.6 nano vim vim-common vim-runtime

The following packages will be upgraded:

  libpython3.6-minimal libpython3.6-stdlib python3.6 python3.6-minimal

4 upgraded, 5 newly installed, 0 to remove and 9 not upgraded.

Need to get 12.4 MB of archives.

After this operation, 37.8 MB of additional disk space will be used.

Do you want to continue? [Y/n] 

Get:1 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3.6 amd64 3.6.9-1~18.04ubuntu1 [203 kB]

Get:2 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpython3.6-stdlib amd64 3.6.9-1~18.04ubuntu1 [1710 kB]

Get:3 http://ap-seoul-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3.6-minimal amd64 3.6.9-1~18.04ubuntu1 [1609 kB]       


ubuntu@cloud1-instance-20200502-1107:~$ sudo nano /etc/ssh/sshd_config 


# To disable tunneled clear text passwords, change to no here!

PasswordAuthentication yes

#PermitEmptyPasswords no


본래 service ssh restart 하면, 적용이 되나, 실제로 이미지에 문제가 있어서 재시작이 되지 않아서 인스턴스 재부팅을 한번 해줍니다.



이후에는 아래와 같이 비밀번호로 로그인이 가능합니다. 


상기 설정에서 root 계정 로그인은 활성화를 하지 않았기 때문에, sudo su 로 root 계정 전환이 가능합니다.


이렇게 사용해도 별 문제가 없고, 보안이 우려되시면, ssh-keyscan 을 통해서 키를 편하게 추가하고 패스워드 인증을 다시 disable 하시면 됩니다.


PS C:\Users\USER> ssh ubuntu@140.238.19.22

The authenticity of host '140.238.19.22 (140.238.19.22)' can't be established.

ECDSA key fingerprint is SHA256:i5+9QkPHfjNTfA91hjSa9FR38GmwTrBF1hCkjaWoXSo.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '140.238.19.22' (ECDSA) to the list of known hosts.

ubuntu@140.238.19.22's password:

Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 5.0.0-1014-oracle x86_64)


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

 * Management:     https://landscape.canonical.com

 * Support:        https://ubuntu.com/advantage


This system has been minimized by removing packages and content that are

not required on a system that users do not log into.


To restore this content, you can run the 'unminimize' command.


14 packages can be updated.

9 updates are security updates.


Last login: Sat May  2 02:09:54 2020 from 132.145.85.85

ubuntu@cloud1-instance-20200502-1107:~$





8. 방화벽 설정


22번 포트 외에 추가할 포트가 있다면 방화벽 설정을 해주셔야 합니다.


저는 ssh 포트를 22번 말고 22335 포트로 변경하기 위해서 방화벽 설정을 진행해 보았습니다.


1. 인스턴스 내부의 iptables 설정 추가


하기 경로로 이동하여 포트를 추가합니다.


ubuntu@cloud2-instance-20200502-1108:~$ sudo vim /etc/iptables/rules.v4 


# CLOUD_IMG: This file was created/modified by the Cloud Image build process

# iptables configuration for Oracle Cloud Infrastructure


# See the Oracle-Provided Images section in the Oracle Cloud Infrastructure

# documentation for security impact of modifying or removing these rule


*filter

:INPUT ACCEPT [0:0]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [463:49013]

:InstanceServices - [0:0]

-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

-A INPUT -p icmp -j ACCEPT

-A INPUT -i lo -j ACCEPT

-A INPUT -p udp --sport 123 -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m tcp --dport 22335 -j ACCEPT

-A INPUT -j REJECT --reject-with icmp-host-prohibited


혹시 차후에 접근이 안될 때를 대비하여 22 포트는 남겨 둡니다.


2. 클라우드 콘솔로 이동하여 방화벽 설정 추가


저는 그냥 VM 생성하다가 한 인스턴스에 동일한 방화벽 설정이 추가가 되어 버렸습니다.



생성하실 때 인스턴스 별로 하려면 VCN 생성을 통해 작업하시면 됩니다.


한편, 인스턴스에서 방화벽 설정을 조정하려면 아래와 같이 진행하시면 됩니다.







3. 결론


그냥 방화벽에서 다 열어버린 다음에 iptables 로 컨트롤 하는 것도 좋지 않을까 생각이 드네요. 


일단 초기 세팅 과정중이라 이렇게 넘어갑니다.


이제 바뀐 SSH 포트로 접근을 해보겠습니다.


PS C:\Users\USER> ssh ubuntu@140.238.19.22 -p 22335

ubuntu@140.238.19.22's password:

Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 5.0.0-1014-oracle x86_64)


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

 * Management:     https://landscape.canonical.com

 * Support:        https://ubuntu.com/advantage


This system has been minimized by removing packages and content that are

not required on a system that users do not log into.


To restore this content, you can run the 'unminimize' command.


14 packages can be updated.

9 updates are security updates.


Last login: Sat May  2 02:29:05 2020 from 132.145.85.85

Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 5.0.0-1014-oracle x86_64)


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

 * Management:     https://landscape.canonical.com

 * Support:        https://ubuntu.com/advantage


This system has been minimized by removing packages and content that are

not required on a system that users do not log into.


To restore this content, you can run the 'unminimize' command.


14 packages can be updated.

9 updates are security updates.


Last login: Sat May  2 02:29:05 2020 from 132.145.85.85

ubuntu@cloud1-instance-20200502-1107:~$


완벽합니다.





9. 마치며..


일단 오라클 클라우드 자체가 사양이 그렇게 좋지 않으나, 평생 무료이기 때문에 매력적인 부분입니다.


사양으로 보면 아래와 같습니다.



ubuntu@cloud2-instance-20200502-1108:~$ df -h

Filesystem      Size  Used Avail Use% Mounted on

udev            470M     0  470M   0% /dev

tmpfs            98M  928K   97M   1% /run

/dev/sda1        45G  1.2G   44G   3% /

tmpfs           489M     0  489M   0% /dev/shm

tmpfs           5.0M     0  5.0M   0% /run/lock

tmpfs           489M     0  489M   0% /sys/fs/cgroup

/dev/loop0       25M   25M     0 100% /snap/oracle-cloud-agent/7

/dev/loop2       55M   55M     0 100% /snap/core18/1705

/dev/loop1       28M   28M     0 100% /snap/snapd/6953

/dev/sda15      105M  3.6M  101M   4% /boot/efi

tmpfs            98M     0   98M   0% /run/user/1001


메모리 용량이 발목을 잡으나, 어떻게 쓰던 웹 호스팅 혹은 프록시 혹은 VPN 으로 쓰던 용도는 다양할 것입니다.


그리고, 한가지 두려운 점은 VM 초기화가 필요할 때, Terminate 를 꼭 해야하는 부분이 있습니다.


이 Terminate 는 인스턴스를 날리는 것이기 때문에 무료 사용기간이 끝나면, 프리티어로 재생성이 가능한지 의문입니다.


무료 기간 30일이 지나면 생성이 불가능한 것으로 알고 있어서.. 더럽히지 않고 잘 사용해야할 것으로 보이네요.


추후 IP 를 외우기 힘들기 때문에 제 djjproejct.com 에 도메인으로 붙여서 사용할 예정입니다. 무료 도메인으로는 duckdns 를 쓰시면 됩니다.


감사합니다.


반응형

댓글