Justin의 개발 로그
article thumbnail

 AWS Lightsail 인스턴스 생성

  • AWS -> Lightsail -> Create an instance
    • Linux/Unix
    • OS Only
    • Ubuntu 18.04 LTS
    • Add launch script를 선택하고 다음과 같은 명령어를 입력합니다.

sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config

echo "ubuntu:1q2w3e4r" | chpasswd

service sshd reload

apt-get -y update

apt-get -y install nodejs npm

npm install -g wetty

curl https://gist.githubusercontent.com/subicura/9058671c16e2abd36533fea2798886b0/raw/e5d249612711b14c9c8f44798dea1368395e86a9/wetty.service -o /lib/systemd/system/wetty.service

systemctl start wetty

systemctl enable wetty


  • Choose your instance plan
    • Price per month
    • $20 - 4GB / 2vCPUs / 80 GB SSD / 4TB
  • Identify your instance : 아무거나 원하는 이름으로
  • 인스턴스가 Running으로 바뀌면 다음 진행

 

sed 명령어

...더보기

sed 명령어 : Stream EDitor의 약자

-i : edit files in place 즉, 일치하면 파일을 수정한다.

 

예)

$echo "before" >> test.txt

$cat test.txt

before

 

$sed -i.bak 's/before/after/' test.txt 

$cat test.txt

after

 

$ls -l

test.txt

test.txt.bak

 

$cat test.txt.bak

before

 

chpasswd 명령어

...더보기

chpasswd : 비밀번호 변경 명령어

기본 사용법

$chpasswd

ubuntu:변경할비밀번호

 

파일 입력을 이용해 여러 계정의 비밀번호 변경

$chpasswd filename

파일에 있는 id:password 패턴을 읽어서 동시에 여러 계정의 비밀번호를 설정함

 

파이프라인을 이용한 shell 응용

echo "ubuntu:password1$"|chpasswd

제공된 표준 파이프라인의 값을 읽어 비밀번호를 변경

 

Wetty 설정

...더보기

[Unit]

Description=wetty service

After=network.target

StartLimitIntervalSec=0

 

[Service]

Type=simple

Restart=always

RestartSec=1

User=root

ExecStart=/usr/local/bin/wetty -p 4200 --base=/

 

[Install]

WantedBy=multi-user.target

 

 

WeTTy javascript terminal 설명
WeTTy = Web TTy

https://www.npmjs.com/package/wetty?activeTab=readme

 

 

Ubuntu 인스턴스 방화벽 오픈

  • 인스턴스 클릭
  • 상세에서 Networking  클릭
  • 아래와 같이 22, 80, 443, 4200 오픈 
    (진행 과정에서 필요한 포트가 있으면 추가 오픈 예정)
  • 귀찮으면  All 로 오픈도 가능 (각자 책임)

 

Shell 접속

Public IP의 4200 포트로 접속하면 wetty javascript terminal에 접속 가능합니다.

웹 브라우저를 띄워 IP:4200으로 접속을 시도해 보세요.

 

*다음 강좌를 이어 진행하지 않은 분은 비용 발생을 최소화하기 위해 장비를 제거하세요.

 Lightsail로 생성한 장비는 중지시켜도 비용이 과금됩니다.

 비용 과금을 막으려면 반드시 장비를 제거(반납, 삭제) 하셔야 합니다.

profile

Justin의 개발 로그

@라이프노트

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!