Debian 初始設定

Basic

  1. as root via ssh and install sudo.
    1. #Client side
      $ ssh root@hostname or hostip
    2. After loging remote server
      $ apt install sudo -y
    3. Set locale config
      $ sudo apt install locales -y
      then
      $ sudo dpkg-reconfigure locales
      or
      $ sudo vim /etc/locale.gen
      then
      $ sudo /usr/sbin/locale-gen
      then logout and loging back.
  2. Create new user {user} and config security setting.
    1. Create new user
      $ adduser {user}
      $ sudo usermod -aG sudo {user}
    2. Config ssh setting
      Do {SSH Related} Section
  3. Logout from root and loging as new user {user}.
    1. Logout from root
      $ logout
    2. Loging as new user {user}
      #Client side
      $ ssh {user}@hostname or hostip
  4. Install zsh & git & oh-my-zsh and setting theme to Agnoster.
    $ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    $ nano .zshrc
    change=> ZSH_THEME="robbyrussell" to ZSH_THEME="agnoster" ,and reload zsh.
    $ source .zshrc
    

SSH Related

  1. Update remote server's sshconfig.
    $ sudo nano /etc/ssh/sshd_config
    change=> PermitRootLogin yes
    change=> PasswordAuthentication no
    change=> PubkeyAuthentication yes
  2. Add Client ssh key to remote server.
    $ ssh-copy-id -i ~/.ssh/id_ed25519.pub
    {lsheep}@hostname or hostip
  3. Reloging to remote server from client to test it.
    $ sudo /etc/init.d/ssh restart
    or
    $ sudo service sshd restart

Docker Related

  1. Install Docker
    $ sudo apt-get update
    
    $ sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y
    
    $ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
    
    $ echo \
    "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
    $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    
    $ sudo apt-get update
    $ sudo apt-get install docker-ce docker-ce-cli containerd.io -y
    
  2. Config docker to non root user
    $ sudo groupadd docker
    $ sudo usermod -aG docker $USER
    $ newgrp docker
    $ docker run hello-world
    
  3. Config portainer
    $ sudo systemctl edit docker.service