Search

업무용 맥과 딥러닝서버를 세팅하기 위한 가이드

Overview

이 글은 macOS 기반 개발환경 + 리눅스 딥러닝 서버 세팅을 통합적으로 관리하고 싶은 개발자 및 연구자를 위한 가이드입니다.

맥 초기 설정하기

1. Homebrew 설치

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" # shellenv echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)" # 설치 확인 brew --version
Shell
복사

2. 필수 어플리케이션 설치

Brew를 통한 자동설치
brew install --cask rectangle alfred iterm2 raycast qlstephen betterzip
Shell
복사
Rectangle / Magnet (창 분할정리)
Alfred (Spotlight 대체)
Raycast (Alfred 보다 현대적)
Iterm2 (Terminal 대체)
qlstephen (Quicklook 플러그인)
Better Zip 5 (압축관리 및 Quicklook 플러그인)
수동 설치 앱
Cursor (IDE, VSCode 대체)
Forklift 4 (유료, Finder 및 FTP)
Transmit (유료, FTP)
터미널 패키지 설치
# 필수 brew install git zsh tmux nvitop htop # 필수 폰트 for iterms brew install --cask font-meslo-lg-nerd-font # 추천 brew install bat fzf eza zoxide starship
Shell
복사
필수 설치 패키지
zsh, oh-my-zsh, tmux: Shell
git, git-lfs: Version control
htop, nvitop : Monitoring
추천 패키지
bat: cat의 대체 툴로, 파일을 컬러 하이라이팅과 줄 번호와 함께 출력.
fzf: 터미널에서 사용할 수 있는 fuzzy finder. 명령어 히스토리, 파일 탐색, git 브랜치 선택 등 다양한 상황에서 빠르게 검색 가능.
eza: ls의 모던 대체 툴. 컬러, 아이콘, 트리 뷰, 파일 정보 등 시각적으로 뛰어난 출력 지원.
zoxide: cd의 강화 버전. 자주 가는 디렉토리를 자동으로 학습하고, 짧은 명령어로 빠르게 이동 가능.

3. Iterm2 필수 설정하기

아래 글을 따라서 iterms2 세팅을 완료해주세요.

4. 터미널 초기 설정하기

Alias 및 .zshrc 설정
각종 편의 alias와 함수를 모아둔 커스텀 alias를 공유합니다.
cd ~ git clone git@gist.github.com:930e01ec1e2d3d652745b5db6a453d1b.git echo '[[ -f ~/.sh_aliases ]] && source ~/.sh_aliases' >> ~/.zshrc source ~/.zshrc
Shell
복사
zsh 테마 및 플러그인 설치 (starship 테마 추천):
# 테마 설치 brew install starship # plugin 설치 git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
Shell
복사
~/.zshrc에 다음 라인 추가:
plugins=( git z fzf zsh-autosuggestions zsh-syntax-highlighting ) eval "$(starship init zsh)" eval "$(zoxide init zsh)" [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
Shell
복사

4. SSH 설정

SSH Key 생성
로컬 개발환경(macOS)에서 원격 서버나 GitHub 등 외부 서비스에 접속할 때 사용할 SSH 키를 생성합니다.
ssh-keygen -t ed25519 -C "your_email@example.com"
Shell
복사
기본 경로: ~/.ssh/id_ed25519 공개 키: ~/.ssh/id_ed25519.pub
생성된 공개키는 서버의 ~/.ssh/authorized_keys 또는 GitHub/Bitbucket 등 서비스에 등록해야 합니다.
# 내용 클립보드에 복사 pbcopy < ~/.ssh/id_ed25519.pub
Shell
복사
github.com > Settings > SSH and GPG keys > New SSH Key에 등록
~/.ssh/config 설정
SSH 접속을 편리하게 하기 위해 자주 사용하는 서버 정보를 ~/.ssh/config에 저장합니다.
Host my-server HostName 11.22.33.44 User ubuntu IdentityFile ~/.ssh/id_ed25519 Port 22 ForwardAgent yes
Shell
복사
→ ssh my-server만으로 접속 가능해집니다.
(고급) Jump Host (중간서버 경유)
Host jump HostName 11.22.33.44 User ubuntu IdentityFile ~/.ssh/id_ed25519 Host internal HostName 192.168.1.100 User ubuntu ProxyJump jump
Shell
복사
→ ssh internal 실행 시 자동으로 jump 서버를 거쳐 내부 서버에 접속합니다.
(필수) 권한 설정
chmod 700 ~/.ssh chmod 600 ~/.ssh/id_ed25519 chmod 644 ~/.ssh/id_ed25519.pub chmod 600 ~/.ssh/config
Shell
복사
접속 테스트
ssh -T git@github.com # GitHub 연결 테스트 ssh my-server # 설정된 서버 접속 테스트
Shell
복사

딥러닝 서버 초기 설정하기

딥러닝 서버에서는 시스템 모니터링, 셸 환경 구성, GPU 상태 확인 등이 중요합니다. 아래는 Ubuntu 기준으로 추천하는 기본 패키지입니다.
sudo apt update && sudo apt upgrade -y sudo apt install -y \ git \ zsh \ tmux \ curl \ wget \ build-essential \ htop \ unzip \ neovim \ ca-certificates \ software-properties-common # Monitoring pip install gpustat nvitop # oh-my-zsh sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Shell
복사

터미널 초기 설정하기

서버에서도 일관된 zsh 환경을 쓰기 위해 위와 동일한 설정을 추천합니다.
# alias 설정 cd ~ && git clone git@gist.github.com:930e01ec1e2d3d652745b5db6a453d1b.git # Starship 테마 설치 curl -sS https://starship.rs/install.sh | sh # fzf git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf ~/.fzf/install # plugin 설치 curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
Shell
복사
~/.zshrc에 다음 라인 추가:
plugins=( git z fzf zsh-autosuggestions zsh-syntax-highlighting ) eval "$(starship init zsh)" eval "$(zoxide init zsh)" [[ -f ~/.sh_aliases ]] && source ~/.sh_aliases [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
Shell
복사

Micromamba 설치 (Python 환경 관리)

curl micro.mamba.pm/install.sh | bash echo 'eval "$($HOME/.local/bin/micromamba shell hook -s zsh)"' >> ~/.zshrc
Shell
복사

서버 보안 설정

기초적인 보안을 위해 방화벽을 설정하고 기본 포트를 222222로 변경합니다.
SSH 설정 변경 (/etc/ssh/sshd_config)
# /etc/ssh/sshd_config # Port 22 # 기존 Port 2222 # 변경 PermitRootLogin no PasswordAuthentication no
Shell
복사
기본 보안 구성:
sudo apt install ufw -y # SSH 방화벽 설정 sudo ufw default deny incoming sudo ufw default allow outgoing sudo ufw allow 2222/tcp sudo ufw enable
Shell
복사
수정 후 SSH 재시작
sudo systemctl restart ssh
Shell
복사
포트 변경 전 반드시 새 세션을 열어 테스트 가능성 확보하고 작업하세요.
Fail2Ban 설치 및 설정:
Fail2Ban은 비정상적인 SSH 접속 시도를 감지하고 자동으로 IP 차단해주는 보안 툴입니다.
# 설치 sudo apt install fail2ban -y # 설정 파일 복사 및 수정 sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local sudo nano /etc/fail2ban/jail.local
Shell
복사
sshd 관련 설정 예시: jail.local
# /etc/fail2ban/jail.local [DEFAULT] # 화이트리스트 설정 ignoreip = 127.0.0.1/8 ::1 11.22.33.44 198.51.100.0/24 [sshd] enabled = true port = 2222 logpath = %(sshd_log)s backend = systemd findtime = 10m bantime = 1h maxretry = 5
Shell
복사
위 설정은 10분 내 5번 실패 시 1시간 차단합니다.
화이트리스트 설정 (ignoreip):
127.0.0.1/8, ::1 → 기본 로컬 주소
11.22.33.44 → 단일 IP 허용
198.51.100.0/24 → 서브넷 전체 허용
여러 IP는 공백으로 구분
서버 관리자 본인의 공인 IP를 넣는 것을 추천 (ip 확인:curl ifconfig.me)
Fail2Ban 서비스 재시작 및 확인
sudo systemctl restart fail2ban sudo systemctl enable fail2ban sudo fail2ban-client status sudo fail2ban-client status sshd
Shell
복사

설정 동기화 - chezmoi로 Dotfiles 통합 관리하기

딥러닝 서버가 여러대인 환경에서 .zshrc, .ssh/config, alias 등 설정 파일을 통일성 있게 관리하려면 chezmoi를 사용하는 것을 추천합니다.
chezmoi는 dotfiles 버전 관리 + 템플릿 분기 + 보안 파일 암호화를 동시에 지원합니다.

1. chezmoi 설치:

# macOS brew install chezmoi # Linux (Ubuntu 등) sh -c "$(curl -fsLS get.chezmoi.io)"
Shell
복사

2. Dotfiles 초기화 (설정이 완료된 서버/맥에서 시작)

GitHub 저장소 만들기
chezmoi init git@github.com:yourusername/dotfiles.git chezmoi add ~/.zshrc ~/.ssh/config ~/.sh_aliases chezmoi apply
Shell
복사
→ 설정 파일들이 ~/.local/share/chezmoi/ 디렉토리로 이동됨 → Git 저장소에 커밋하고 GitHub에 푸시

3. 동기화 할 서버에서 dotfiles 통합 적용

chezmoi init git@github.com:yourusername/dotfiles.git chezmoi apply
Shell
복사
→ 서버에서도 동일한 설정이 반영됨

(고급) 운영체제 / 호스트 이름 분기

.zshrc.tmpl 파일에서 다음처럼 조건 분기 가능:
{{ if eq .chezmoi.hostname "dl-server" }} export PATH="/opt/custom-server-tools/bin:$PATH" {{ else }} export PATH="/opt/homebrew/bin:$PATH" {{ end }}
Shell
복사
chezmoi.hostname은 시스템의 호스트명을 기준으로 자동 분기됩니다.

(고급) 민감 정보 암호화

예: SSH 개인 키, API 키 등
chezmoi add --encrypt ~/.ssh/id_ed25519
Shell
복사
→ dot_ssh/id_ed25519.tmpl.age로 저장됨 → 다른 기기에서도 chezmoi init 시 GPG 또는 age 비밀번호 입력으로 복원 가능

(고급) ignore 목록 관리

~/.chezmoiignore에 파일 또는 경로 추가 시 버전 관리에서 제외할 수 있습니다:
.dot_gitconfig .secret_env
Shell
복사

추천 디렉토리 구조 예시

~/.local/share/chezmoi/ ├── dot_zshrc.tmpl ├── dot_sh_aliases ├── dot_ssh/ │ ├── config │ └── id_ed25519.tmpl.age ├── private_dot_envrc.tmpl ├── run_once_setup.sh.tmpl
Shell
복사

유용한 명령어 요약

명령어
설명
chezmoi apply
변경 적용
chezmoi diff
변경 전후 비교
chezmoi add ~/.파일
파일 추가
chezmoi cd
chezmoi 디렉토리로 이동
chezmoi edit ~/.파일
템플릿 파일 열기
chezmoi status
추적 중인 파일 확인