====== Setting Up Ubuntu Server (우분투 서버 설정하기) ======
> Ubuntu Server 설치 후 필요한 기본 설정
===== 패키지 업데이트 및 업그레이드 =====
* 패키지 설치 시 반드시 먼저 실행 sudo apt update && sudo apt upgrade -y
* 업데이트 실패 시 dns 확인 및 설정 (([[https://hs5555.tistory.com/44|[Linux] Ubuntu 업데이트 서버 연결 에러 (apt-get update 에러) @hs5555.tistory.com]]))
* sudo vi /etc/network/interfaces
* 내용 추가 dns-nameservers 8.8.8.8 8.8.4.4 1.1.1.1
* sudo vi /ect/resolv.conf
* 내용 추가
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 1.1.1.1
* ''/ect/resolv.conf'' 파일 수정이 안될 경우 (([[https://stackoverflow.com/questions/19432026/how-do-i-edit-resolv-conf|linux - How do I edit resolv.conf? - Stack Overflow @stackoverflow.com]]))
* sudo rm /etc/resolv.conf ;# to remove the symlink
sudo vi /etc/resolv.conf ;# to create a regular file
===== Set Timezone (타임 존 세팅) =====
* 타임 존 설정 sudo dpkg-reconfigure tzdata
* 시간 설정 sudo timedatectl set-local-rtc yes
===== net-tools, openssh server 설치 =====
sudo apt install net-tools openssh-server -y
===== firewall 설치 및 설정 =====
- ufw 패키지 설치 (설치 전 패키지 업데이트) sudo apt install ufw -y
- ufw 사용 설정 sudo ufw enable
- ufw 상태 확인 sudo ufw status
- ssh 허용 설정 sudo ufw allow ssh
* 예제) 3389 포트 허용 설정 sudo ufw allow from any to any port 3389
- ufw 설정 적용 sudo ufw reload
===== rsync 서버 설정 =====
- sudo apt install rsync -y
- sudo systemctl start rsync
- sudo vi /etc/rsync.conf
* [web] -> 사용할 rsync 서비스 이름
path = /home/web -> 데이터원본 경로
comment = rsync_test -> 코멘트
uid = root -> 권한 사용자
gid = root -> 권한 그룹
use chroot = yes
read only = yes
hosts allow = 192.168.10.10 -> rsync 클라이언트IP, localhost일 경우 입력하지 않아도 된다
max connections = 10
timeout = 30
- sudo systemctl restart rsync
===== cron 설정 =====
- cron 설정 실행 crontab -e
- 내용 편집
* 예제1) rsync 매일 오전 3시에 실행 0 3 * * * rsync -avrzp --delete {user}@{url}::{rsync section name} {destination directory}
* 예제2) ddns 업데이트 실행 */5 * * * * /usr/local/bin/curl -s 'https://ddns.dnszi.com/set.html?user={user id}&auth={auth key}&domain={domain}&record='
* 예제3) 0 5 1 * * tar zcfp /{dest dir}/archive-$(date +\%Y\%m\%d).tar.gz /{source dir}
- sudo 없이 cron 실행 설정
sudo ALL=NOPASSWD: /usr/sbin/service cron start
sudo systmctl daemon-reload
===== 네트워크 드라이브 연결 및 설정 =====
- 네트워크 드라이브 연결에 필요한 패키지 설치 (설치 전 패키지 업데이트) sudo apt install nfs-common cifs-utils -y
- 마운트할 디렉토리 생성 sudo mkdir -p /mnt/{name to mount}
- 디렉토리 권한 설정 sudo chmod 777 /mnt/{name to mount}
- 드라이브 마운트
* samba mount -t cifs -o rw,vers=3.0,credentials=/etc/samba/.smbcreds {source url} {destination directory}
* nfs mount -t nfs {source url} {destination directory}
- 부팅시 자동 마운트 설정
- 인증 정보 파일 생성 sudo vi /etc/samba/.smbcreds
* 내용 편집 username={user id}
password={passwrod}
- file system table 편집 sudo vi /etc/fstab
* //{source ip}/{directory} {destination directory} cifs credentials=/etc/samba/.smbcred,uid=34,gid=34,defaults 0 0
===== rdp(xrdp) 설치 =====
- xrdp 상태 확인 sudo systemctl status xrdp
- xrdp 패키지 설치 (설치 전 패키지 업데이트) sudo apt install xrdp
- xrdp 데몬 실행 sudo systemctl enable --now xrdp
- xrdp 사용자 추가 sudo adduser xrdp ssl-cert
===== 기타 참고 =====
* 버전 정보
* lsb_release -a
* uname -a
* cat /etc/issue
* cat /etc/*release
* motd ''/etc/default/motd-news''