Table of Contents

Setting Up Ubuntu Server (우분투 서버 설정하기)

Ubuntu Server 설치 후 필요한 기본 설정

패키지 업데이트 및 업그레이드

Set Timezone (타임 존 세팅)

net-tools, openssh server 설치

sudo apt install net-tools openssh-server -y

firewall 설치 및 설정

  1. ufw 패키지 설치 (설치 전 패키지 업데이트)
    sudo apt install ufw -y
  2. ufw 사용 설정
    sudo ufw enable
  3. ufw 상태 확인
    sudo ufw status
  4. ssh 허용 설정
    sudo ufw allow ssh
    • 예제) 3389 포트 허용 설정
      sudo ufw allow from any to any port 3389
  5. ufw 설정 적용
    sudo ufw reload

rsync 서버 설정

  1. sudo apt install rsync -y
  2. sudo systemctl start rsync
  3. 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
  4. sudo systemctl restart rsync

cron 설정

  1. cron 설정 실행
    crontab -e
  2. 내용 편집
    • 예제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}
  3. sudo 없이 cron 실행 설정
    sudo ALL=NOPASSWD: /usr/sbin/service cron start
    sudo systmctl daemon-reload

네트워크 드라이브 연결 및 설정

  1. 네트워크 드라이브 연결에 필요한 패키지 설치 (설치 전 패키지 업데이트)
    sudo apt install nfs-common cifs-utils -y
  2. 마운트할 디렉토리 생성
    sudo mkdir -p /mnt/{name to mount}
  3. 디렉토리 권한 설정
    sudo chmod 777 /mnt/{name to mount}
  4. 드라이브 마운트
    • 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}
  5. 부팅시 자동 마운트 설정
    1. 인증 정보 파일 생성
      sudo vi /etc/samba/.smbcreds
      • 내용 편집
        username={user id}
        password={passwrod}
    2. 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) 설치

  1. xrdp 상태 확인
    sudo systemctl status xrdp
  2. xrdp 패키지 설치 (설치 전 패키지 업데이트)
    sudo apt install xrdp
  3. xrdp 데몬 실행
    sudo systemctl enable --now xrdp
  4. xrdp 사용자 추가
    sudo adduser xrdp ssl-cert

기타 참고