'etc'에 해당되는 글 5건

  1. 2020.05.18 ssh key로 서버 접속
  2. 2020.05.18 bash Prompt 설정
  3. 2020.04.20 ubuntu user 생성
  4. 2020.03.16 git command
  5. 2020.02.19 ansible로 ubuntu user 생성

ssh key로 서버 접속

etc 2020. 5. 18. 21:39

 

# ssh key 생성

# SSH key 생성 
$ ssh-keygen -b 4096 -f ~/.ssh/id_rsa -N "" 

# ssh key를 접속할 서버로 copy(계정 및 password 필요)
$ ssh-copy-id -i ~/.ssh/id_rsa.pub <user>@<node_ip_address> 

 

# ~/.ssh/ 하위에 config 파일 확인(없으면 생성)

$ ls -al .ssh/
total 32
drwx------   6 root  staff   192  5  8 00:08 .
drwxr-xr-x+ 34 root  staff  1088  5  8 00:08 ..
-rwx------   1 root  staff   100  5  8 00:08 config
-rw-------   1 root  staff  1856  3  8 17:41 id_rsa
-rw-r--r--   1 root  staff   418  3  8 17:41 id_rsa.pub
-rw-r--r--   1 root  staff  1399  4 19 14:06 known_hosts

 

# config 파일 내용


### minikube
Host minikube
    HostName 123.123.123.123
    #Port 22222 포트 변경 필요시
    User root
    IdentityFile ~/.ssh/id_rsa

$ ssh minikube 로 서버 접속

 

 

'etc' 카테고리의 다른 글

bash Prompt 설정  (0) 2020.05.18
ubuntu user 생성  (0) 2020.04.20
git command  (0) 2020.03.16
ansible로 ubuntu user 생성  (0) 2020.02.19
Posted by jerymy
,

bash Prompt 설정

etc 2020. 5. 18. 21:27

# user의 홈 디렉토리 .bash_profile 수정

 

export PATH="/usr/local/bin:$PATH"
# colors
GREEN='\e[0;32m\]'
B_GREEN='\e[1;32m\]'
MAGENTA='\e[0;35m\]'
B_MAGENTA='\e[1;35m\]'
YELLOW='\e[0;33m\]'
B_YELLOW='\e[1;33m\]'
RED='\e[0;31m'
BLUE='\e[0;34m'
B_BLUE='\e[1;34m'
CYAN='\e[0;36m\]'
COLOR_END='\[\033[0m\]'


#export PS1="${BLUE}\u: ${GREEN}\w ${COLOR_END}\ $ "
export PS1="${GREEN}\u ${B_BLUE}\w ${COLOR_END}\$ "

'etc' 카테고리의 다른 글

ssh key로 서버 접속  (0) 2020.05.18
ubuntu user 생성  (0) 2020.04.20
git command  (0) 2020.03.16
ansible로 ubuntu user 생성  (0) 2020.02.19
Posted by jerymy
,

ubuntu user 생성

etc 2020. 4. 20. 11:06

ubuntu에 user01 계정 생성

 

# user01 계정 생성

$ adduser user01

# password 2번 입력하고, 추가 정보는 엔터만 치면됨. 마지막에 Y 입력

 

# sudo 추가

$ usermod -aG sudo user01

 

# user01을 docker 실행 그룹에 추가

$ usermod -aG docker user01

 

'etc' 카테고리의 다른 글

ssh key로 서버 접속  (0) 2020.05.18
bash Prompt 설정  (0) 2020.05.18
git command  (0) 2020.03.16
ansible로 ubuntu user 생성  (0) 2020.02.19
Posted by jerymy
,

git command

etc 2020. 3. 16. 17:24

# 환경설정, --global , --local

$ git config --global user.name "MyName"

$ git config --global user.email "MyMail@gmail.com"

 

# config 확인

$ git config --list

 

# 초기화

$ git init

# 초기화 + 디렉토리 자동생성 -dir_name

$ git init -dir_name

 

# 현재 git 상태

$ git status

 

# add : working tree -> stage

$ git add filename

 

# 변경사항 확인, working tree <-> stage, commit 이후에는 안됨..

$ git diff

 

# commit 내용 확인

$ git log

# commit된 파일까지 함께 보기

$ git log --stat

 

# commit : stage -> repository

$ git commit -m "message1"

 

# commit : working tree --> repository, 한번 commit 한 파일만 가능

$ git commit -am "message1"

 

# commit 메세지 수정

$ git commit --amend

 

 

# chechout, working tree 수정 되돌리기. 복구 안됨

$ git chechout

 

# stage 되돌리기, add 이후에 사용, 

$ git reset HEAD 파일명

 

# commit 되돌리기, working tree에만 수정내용이 존재하는 상태가 됨

$ git reset HEAD^

 

# 특정 commit으로 되돌리기

$ git reset --hard 커밋해시

 

# 커밋 삭제하지 않고 되돌리기

$ git revert 커밋해시

 

'etc' 카테고리의 다른 글

ssh key로 서버 접속  (0) 2020.05.18
bash Prompt 설정  (0) 2020.05.18
ubuntu user 생성  (0) 2020.04.20
ansible로 ubuntu user 생성  (0) 2020.02.19
Posted by jerymy
,

ansible로 ubuntu user 생성

etc 2020. 2. 19. 15:45

1. ansible 설치 -> 사전에 python 설치 확인

# 방법 1 - from ansible documentation 
$ sudo apt update
$ sudo apt install software-properties-common
$ sudo apt-add-repository --yes --update ppa:ansible/ansible
$ sudo apt install ansible


# 방법 2 - from ansible documentation
$ pip install ansible

 

2. 호스트 등록

$ vi /etc/ansible/hosts

# 아래 양식으로 등록(아래 이미지 참조)

[web]
호스트IP 1
호스트IP 2

3. 연결 테스트

# 연결 테스트
$ ansible all -m ping
$ ansible worker1 -m ping

 

4. ssh key 생성 및 복사

# SSH key 생성
$ ssh-keygen -b 4096 -f ~/.ssh/id_rsa -N ""

# 인증키에 등록
$ cat ~/.ssh/id_rsa.pub | sudo tee -a ~/.ssh/authorized_keys

# 인증키를 각 노드에 추가
$ ssh-copy-id -i ~/.ssh/id_rsa.pub <user>@<node_ip_address>
예)
$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@proxy
$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@management
$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@worker1
$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@worker2

ssh-copy-id -i ~/.ssh/id_rsa.pub root@169.56.170.168

# 모든 node에서 ssh 재시작
$ sudo systemctl restart sshd

 

5. ssh key 복사후 ping 테스트 결과 (아래 이미지)

 

 

6. yaml 작성

# create-user.yaml

- name: 사용자 추가
  hosts: all
  become: true
  tasks:
    - name: 사용자 이름 생성
      user:
        name: "{{ item }}"
        shell: /bin/bash
      with_items: "{{ USER_NAME }}"
    - name: 패스워드 변경
      user:
        name: "{{ item }}"
        password: "{{ PASSWORD | password_hash('sha512') }}"
      with_items: "{{ USER_NAME }}"
    - name: sudoers.d 추가
      copy:
        content: |
          %{{item}} ALL=(ALL) NOPASSWD: ALL
        dest: "/etc/sudoers.d/{{item}}"
        owner: root
        group: root
        mode: 0440
        validate: "/usr/sbin/visudo -c -f '%s'"
      with_items: "{{ USER_NAME }}"
  vars:
    USER_NAME:
    - "user01"
    - "user02"
    - "user03"
    - "user04"
    - "user05"
    - "user06"
    - "user07"
    - "user08"
    - "user09"
    - "user10"
    - "user11"
    - "user12"
    - "user13"
    - "user14"
    - "user15"
    - "user16"
    - "user17"
    - "user18"
    - "user19"
    - "user20"
    - "user21"
    - "user22"
    - "user23"
    - "user24"
    - "user25"
    - "user26"
    - "user27"
    - "user28"
    - "user29"
    - "user30"


7. playbook 실행

# 명령어 실행
$ ansible-playbook create-user.yaml --extra-vars "PASSWORD=your_password"

# 로그인시 프롬프트가 $ 이고 history나 화살표로 이전 명령어 보이기가 실행 안되면
# bin/sh로 실행되는것 -->  vi /etc/passwd 열어서 sh를 -> bash 로 변경하면 됨

8. ICP cluster 접근을 위한 추가 작업

  • root계정으로 cloudctl, kubectl 설치하고, ICP 화면에서 클라이언트 구성 복사해서 실행하면 정상 연결됨
  •  
  • cloudctl login https://icp-cluster:8443
  • 로그인
  • kubectl 명령 실행 가능함....
  •  
  • cloudctl login -a https://icp-cluster:8443 --skip-ssl-validation

 

'etc' 카테고리의 다른 글

ssh key로 서버 접속  (0) 2020.05.18
bash Prompt 설정  (0) 2020.05.18
ubuntu user 생성  (0) 2020.04.20
git command  (0) 2020.03.16
Posted by jerymy
,