Tuesday 21 January 2020

Linux alias option command & and install telnet tool

alias k='kubectl'

k


---- Install telnet tool in shell script
apk add curl busybox-extras

Linux password change command

1. To change a password for user named tom in Ubuntu, type:
sudo passwd tom

2. To change a password for root user on Ubuntu Linux, run:
sudo passwd root

3. And to change your own password for Ubuntu, execute:
passwd

Monday 20 January 2020

Linux - Kill port

netstat -nlp | grep 8000

sudo fuser -k 8000/tcp

netstat -nlp | grep 8000

Tuesday 14 January 2020

- Install & run "Visual Studio Code Server" in Ubuntu

1. run this command
wget https://github.com/cdr/code-server/releases/download/2.1688-vsc1.39.2/code-server2.1688-vsc1.39.2-linux-x86_64.tar.gz
tar xvfz code-server2.1688-vsc1.39.2-linux-x86_64.tar.gz
sudo mv code-server2.1688-vsc1.39.2-linux-x86_64/code-server /usr/local/bin
mkdir ~/project
sudo curl https://gist.githubusercontent.com/subicura/d025000486d30d92dfa6ccc523c3f5e3/raw/2e93bb0dca992523a3e3a6fdba95d2f3526c52db/codeserver.service -o /lib/systemd/system/codeserver.service
sudo systemctl start codeserver
sudo systemctl enable codeserver

2. check your port
ubuntu@ip-172-26-0-243:~$ sudo systemctl status codeserver
● codeserver.service - Code Server IDE
   Loaded: loaded (/lib/systemd/system/codeserver.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2020-01-15 01:51:52 UTC; 1min 56s ago
 Main PID: 4755 (code-server)
    Tasks: 23 (limit: 4704)
   CGroup: /system.slice/codeserver.service
           ├─4755 /usr/local/bin/code-server --port 8000 /home/ubuntu/project
           └─4777 /usr/local/bin/code-server --port 8000 /home/ubuntu/project

> 8080 is the port or VS Code Server

3. Access server http:/111.111.111.111:8080
4. move directory and get password

ubuntu@ip-172-26-0-243:~$ cd project

ubuntu@ip-172-26-0-243:~$ PASSWORD=1q2w3e4r nohup code-server -p 8000 --allow-http &

ubuntu@ip-172-26-0-243:~$ nohup: ignoring input and appending output to 'nohup.out'

5. access  server http:/111.111.111.111:8080 - Password - 1q2w3e4r (login)
 
==========  ReStart ===================================

* Restart Visual Studio Code Server
ubuntu@ip-172-26-0-243:~$ rm -r project

ubuntu@ip-172-26-0-243:~$ cd project

ubuntu@ip-172-26-0-243:~$ PASSWORD=1q2w3e4r nohup code-server -p 8000 --allow-http &

access  server http:/111.111.111.111:8080 - Password - 1q2w3e4r (login)


- Install and run wetty in Ubuntu 18.04 LTS ( with Amazon Lightsail )

- Install and run wetty in Ubuntu 18.04 LTS ( with Amazon Lightsail )

org : https://www.youtube.com/watch?v=4T6wKk_ZWCM

1. Go to Amazon Lightsail
2. Create Instance
3. OS only -> Ubuntu 18.04 LTS
4. $20 > 4TB
4-1. put below user data ( Add launch script )
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
echo "ubuntu:1q2w3e4r" | chpasswd

5. Create Instance
  - put this script under "Add launch script"
   sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
echo "ubuntu:1q2w3e4r" | chpasswd
service sshd reload

6. Go into the instance and change the network to "All TCP"
7. copy ip of new instane and try to access from browser
   http://http://13.231.170.42:4200/
   Fail - cannot access
8. Go to "Connect" and "Connect using SSH"
9. run below command one by one

sudo service sshd reload

sudo apt-get -y update

sudo apt-get -y install nodejs npm

sudo npm install -g wetty

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

sudo systemctl start wetty

sudo systemctl enable wetty

10. Access again with ip : http://http://13.231.170.42:4200/
id : ubuntu - Pw : 1q2w3e4r

Wednesday 8 January 2020

Thursday 2 January 2020

Installing aws-iam-authenticator

- Error : bash: aws-iam-authenticator: command not found

- Solution
https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html#w159aac27c11b5b3

aws cli command - get identity , account, user ID, ARN

kiyoungh:~/environment $ aws sts get-caller-identity

aws config setting command with bash file in linux EC2

export AWS_REGION=$(curl -s 169.254.169.254/latest/dynamic/instance-identity/document | jq -r '.region')
echo "export AWS_REGION=${AWS_REGION}" >> ~/.bash_profile
aws configure set default.region ${AWS_REGION}
aws configure get default.region