[os] ubuntu 기본 설정 변경 및 확인 By starseat 2023-02-13 15:51:31 server/oss Post Tags # 시작 전 root 변경 ``` sudo -i ``` ![image.png](/uploads/_temp/20230213/2b8bbe2ce15b8a25317231791d9fc4c5.png) # OS 확인 ```bash cat /etc/os-release ``` # CPU 및 Memory 확인 ```bash #### cpu lscpu #### memory free -h ``` # 방화벽 확인 ```bash ufw status ``` # swap 확인 ```bash swapon -s ``` # 시간대 변경 세계 표준 시간대 -> 한국 시간대 변경 ```bash rm -f /etc/localtime ln -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime date ``` ![image.png](/uploads/_temp/20230213/45491dbca94c1c49f344fac30316e05a.png) # 호스트 이름 변경 ```bash hostnamectl set-hostname master hostnamectl hostname master ``` # hosts 설정 hostname 으로 통신하기 위한 설정 - AWS 등 클라우드를 사용하게 되면 Public IP 가 아닌 Private IP 사용 ```text vi /etc/hosts 172.31.xxx.xxx master 172.31.xxx.xxx worker1 172.31.xxx.xxx worker2 ``` ![image.png](/uploads/_temp/20230213/dfb154404b58d16bfd6c14543e095d8c.png) # 호스트 이름 변경 및 hosts 설정 후 테스트 ```text # worker2 -> master 접속 테스트 ping master -c 2 ``` ![image.png](/uploads/_temp/20230213/cafc88099ad8bc9384a972374dc4043b.png) # IPv4를 포워딩하여 iptables가 bridge된 traffic 활성화 ```bash # br_netfilter 모듈 로드 cat < worker1, master -> worker2 접속 시 비밀번호 묻지 않고 로그인 ## (worker) 비밀번호 설정 및 ssh 설정 변경 - 아래 항목 worker1, worker2 모두 설정 ```text ### ubuntu 계정 -> root 계정 Last login: Tue Feb 14 12:41:27 2023 from 13.209.1.61 ubuntu@worker1:~$ sudo -i root@worker1:~# ### 비밀번호 변경 root@worker1:~# passwd ubuntu New password: Retype new password: passwd: password updated successfully root@worker1:~# ### sshd config 변경 - "PasswordAuthentication yes" 설정 root@worker1:~# vi /etc/ssh/sshd_config 56 # To disable tunneled clear text passwords, change to no here! 57 #PasswordAuthentication no 58 PasswordAuthentication yes 59 #PermitEmptyPasswords no ### sshd 재시작 root@worker1:~# systemctl restart sshd ``` ## (master) 접속 설정 ```text ### 인증서 생성 ubuntu@master:~$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/ubuntu/.ssh/id_rsa Your public key has been saved in /home/ubuntu/.ssh/id_rsa.pub The key fingerprint is: ... ### 확인 ubuntu@master:~$ ls .ssh/ authorized_keys id_rsa id_rsa.pub ### 인증서를 worker1, worker2 에 전달, 복사 (ubuntu 계정) ### ssh-copy-id worker1 ### ssh-copy-id worker2 ubuntu@master:~$ ssh-copy-id worker1 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/ubuntu/.ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys ubuntu@worker1's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'worker1'" and check to make sure that only the key(s) you wanted were added. ubuntu@master:~$ ssh-copy-id worker2 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/ubuntu/.ssh/id_rsa.pub" The authenticity of host 'worker2 (172.31.0.53)' can't be established. ED25519 key fingerprint is SHA256:GFqXFmapvTk37pfka4VrLKsDLufu2Hh7uuPa3I8zz10. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys ubuntu@worker2's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'worker2'" and check to make sure that only the key(s) you wanted were added. ubuntu@master:~$ ### 접속 테스트 ubuntu@master:~$ ssh worker1 Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-1028-aws x86_64) ... Last login: Tue Feb 14 13:25:42 2023 from 172.31.1.58 ubuntu@worker1:~$ ``` Previous Post [docker] 쿠버네티스 명령어 Next Post [CKA][re] Mock Exam - 1 풀이 (오답 체크)