拿到一台新服务器,你们会有哪些 setups 呢?
分享下自己的一些基础工具,便于运维,以 Debian 为例。
修改 hostname
hostnamectl set-hostname 新的主机名
vi /etc/hosts, 将 127.0.1.1 旧主机名改为 127.0.1.1 新主机名。
添加 ssh public keys
ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote_server
# 或者在服务器上
echo "public key" >> ~/.ssh/authorized_keys
别忘记检查下 /etc/ssh/sshd_config 这一行 PubkeyAuthentication yes。
如果希望直接 root 登录,别忘记 PermitRootLogin prohibit-password 这一个。
最后重启 sshd systemctl restart sshd。
安装 zsh + oh-my-zsh
apt update
apt upgrade
apt install -y zsh
apt install -y curl
apt install -y git
apt install -y vim
apt install -y fzf
chsh -s $(which zsh)
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
配置 .zshrc
export ZSH="$HOME/.oh-my-zsh"
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="dst"
plugins=(git z zsh-autosuggestions fzf)
source $ZSH/oh-my-zsh.sh
export LANG=en_US.UTF-8
export LANGUAGE="en_US"
export LC_ALL=en_US.UTF-8
export LS_OPTIONS='--color=auto'
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='nvim'
# fi
alias vi="vim"
别忘记 source ~/.zshrc。
配置 .vimrc
set encoding=utf-8
set fileencoding=utf-8
set termencoding=utf-8
set number
set cursorline
set autoindent
set smartindent
set tabstop=2
set shiftwidth=2
set expandtab
set ignorecase
set smartcase
set hlsearch
set incsearch
syntax on
set background=dark
colorscheme elflord
set timeoutlen=500
set updatetime=300
额外工具推荐
配置 .tmux.conf
unbind C-b
set -g prefix C-a
bind C-a send-prefix
set-option -g status-bg colour9
set-option -g status-fg colour46
bind-key -n M-Up select-pane -U
bind-key -n M-Down select-pane -D
bind-key -n M-Left select-pane -L
bind-key -n M-Right select-pane -R
set -g status-left-length 30
set -g status-right-length 30
set -g pane-border-style fg=brightblack
set -g pane-active-border-style fg=brightgreen
bind -r < resize-pane -L 2
bind -r > resize-pane -R 2
bind -r + resize-pane -U 1
bind -r - resize-pane -D 1
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
setw -g mode-keys vi
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -selection clipboard -i"
set -g history-limit 10000
仅仅是抛砖引玉,希望各位大佬分享下平时运维服务器有哪些好用工具。