Last active
          December 16, 2023 10:31 
        
      - 
      
 - 
        
Save zmts/b601410b532a0e6e5b38e0c5e9d2b90c to your computer and use it in GitHub Desktop.  
Revisions
- 
        
zmts revised this gist
Aug 19, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ adduser superuser ``` Добавляем его в рутовую группу ``` usermod -aG sudo superuser ``` Добавляем публичный SSH ключ для `superuser` на удаленный сервер. И если в проекте несколько серверов, дабы не создавать сертификат для каждого, можем переиспользовать его на каждом из серверов. То есть проделываем данную процедуру для каждого сервера.  - 
        
zmts revised this gist
Jul 20, 2020 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -121,4 +121,5 @@ alias mv='mv -i' PROMPT='${ret_status} %{$fg[cyan]%}%n::%m[%d]%{$reset_color%} $(git_prompt_info)' RPROMPT='[%T]' ``` `%m` - hostname  - 
        
zmts revised this gist
Jul 20, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -118,7 +118,7 @@ alias rmdir='rm -rfi' alias cp='cp -i' alias mv='mv -i' PROMPT='${ret_status} %{$fg[cyan]%}%n::%m[%d]%{$reset_color%} $(git_prompt_info)' RPROMPT='[%T]' ```  - 
        
zmts revised this gist
Jul 20, 2020 . 1 changed file with 12 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -42,6 +42,18 @@ ssh -i /Users/alex/.ssh/myproject_test [email protected] su ``` __Задать FQDN серверу__ `nano /etc/hostname` ``` mysuperdomain ``` `nano /etc/hosts` ``` 127.0.1.1 mysuperdomain.com mysuperdomain 127.0.0.1 localhost ``` __Время__ ``` @@ -61,7 +73,6 @@ Port 2222 sudo service ssh restart ``` __Загрузить и установить последние обновления системы__ ```  - 
        
zmts revised this gist
Jul 20, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -88,7 +88,7 @@ sudo reboot __Ставим необходимые утилиты__ ``` sudo apt install -y zsh htop git curl wget unzip zip mc iftop psmisc screen ``` __Oh-my-zsh__  - 
        
zmts revised this gist
Jul 18, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -88,7 +88,7 @@ sudo reboot __Ставим необходимые утилиты__ ``` sudo apt install -y zsh htop git curl wget unzip zip mc iftop screen ``` __Oh-my-zsh__  - 
        
zmts revised this gist
Jul 18, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -66,8 +66,8 @@ __Загрузить и установить последние обновлен ``` apt update && apt upgrade ``` `reboot` or `systemctl reboot` __Настраиваем локаль__  - 
        
zmts revised this gist
Jul 18, 2020 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,6 +16,9 @@ ssh-keygen -t rsa -b 4096 -f /Users/alex/.ssh/myproject_test -C "myproject comme - Создаем пользователя(`superuser`) под которым мы в дальнейшем будем ходить по ssh ``` adduser superuser ``` Добавляем его в рутовую группу ``` usermod -aG root superuser ```  - 
        
zmts revised this gist
Jul 18, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,7 @@ ssh-copy-id -i /Users/alex/.ssh/myproject_test.pub [email protected] Теперь публичный ключ размещен на сервере в файле `/home/superuser/.ssh/authorized_keys`. Можем логинится через сертификат. > Обрати внимание логинимся через СЕКРЕТНЫЙ ключ, не публичный! ``` ssh -i /Users/alex/.ssh/myproject_test [email protected]  - 
        
zmts revised this gist
Jul 18, 2020 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,6 +25,9 @@ ssh-copy-id -i /Users/alex/.ssh/myproject_test.pub [email protected] ``` Теперь публичный ключ размещен на сервере в файле `/home/superuser/.ssh/authorized_keys`. Можем логинится через сертификат. > Обрати внимание логинимся через секретный ключ, не публичный! ``` ssh -i /Users/alex/.ssh/myproject_test [email protected] ```  - 
        
zmts revised this gist
Apr 5, 2020 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,6 +36,12 @@ ssh -i /Users/alex/.ssh/myproject_test [email protected] su ``` __Время__ ``` date --set hh:mm ``` `nano /etc/ssh/sshd_config` - Запрещаем логинится по паролю - Запрещаем руту ходить по ssh  - 
        
zmts revised this gist
Apr 4, 2020 . No changes.There are no files selected for viewing
 - 
        
zmts revised this gist
Apr 4, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,7 @@ ssh-copy-id -i /Users/alex/.ssh/myproject_test.pub [email protected] ssh -i /Users/alex/.ssh/myproject_test [email protected] ``` ## Приступим к остальной настройке системы Заходим под рутом и в бой... ```  - 
        
zmts revised this gist
Apr 4, 2020 . 1 changed file with 21 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -76,6 +76,26 @@ sudo reboot __Ставим необходимые утилиты__ ``` sudo apt install -y htop git curl wget unzip zip mc iftop screen ``` __Oh-my-zsh__ ``` sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" ``` __Zsh custom config__ ``` autoload -U +X bashcompinit && bashcompinit alias ls='ls -FGA' alias ll='ls -FGAhl' alias x='clear' alias rm='rm -i' alias rmdir='rm -rfi' alias cp='cp -i' alias mv='mv -i' PROMPT='${ret_status} %{$fg[cyan]%}%n::supersite.com[%d]%{$reset_color%} $(git_prompt_info)' RPROMPT='[%T]' ```  - 
        
zmts revised this gist
Apr 4, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -76,6 +76,6 @@ sudo reboot __Ставим необходимые утилиты__ ``` sudo apt install -y zsh htop git curl wget unzip zip mc iftop screen ```  - 
        
zmts revised this gist
Apr 4, 2020 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -67,10 +67,10 @@ LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LC_TYPE=en_US.UTF-8 ``` Реконфигурируем локали (из списка выбираем `en_US.utf8` и `ru_RU.utf8`, далее по умолчанию ставим `en_US.utf8`) ``` sudo dpkg-reconfigure locales sudo reboot ``` __Ставим необходимые утилиты__  - 
        
zmts revised this gist
Apr 4, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -67,7 +67,7 @@ LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LC_TYPE=en_US.UTF-8 ``` Реконфигурируем локали (из списка выбираем `en_US.utf8` и `ru_RU.utf8`, далее по умолчанию ставим en_US.utf8) ``` dpkg-reconfigure locales reboot  - 
        
zmts revised this gist
Apr 4, 2020 . 1 changed file with 10 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,11 +9,11 @@ ssh-keygen -t rsa -b 4096 -f /Users/alex/.ssh/myproject_test -C "myproject comme ``` Не забываем сделать его бекап ## Первичная настройка сервера/дроплета. Настройка ssh сертификата - Создаем новый Droplet (one-time password) - Логинимся под рутом - Создаем пользователя(`superuser`) под которым мы в дальнейшем будем ходить по ssh ``` adduser superuser usermod -aG root superuser @@ -23,13 +23,19 @@ usermod -aG root superuser ``` ssh-copy-id -i /Users/alex/.ssh/myproject_test.pub [email protected] ``` Теперь публичный ключ размещен на сервере в файле `/home/superuser/.ssh/authorized_keys`. Можем логинится через сертификат. ``` ssh -i /Users/alex/.ssh/myproject_test [email protected] ``` ## Теперь можно приступить к остальной настройке системы. Заходим под рутом и в бой... ``` su ``` `nano /etc/ssh/sshd_config` - Запрещаем логинится по паролю - Запрещаем руту ходить по ssh @@ -43,7 +49,6 @@ Port 2222 sudo service ssh restart ``` __Загрузить и установить последние обновления системы__  - 
        
zmts revised this gist
Apr 4, 2020 . 1 changed file with 10 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,12 +46,14 @@ sudo service ssh restart Теперь можно приступить к остальной настройке системы. __Загрузить и установить последние обновления системы__ ``` apt update && apt upgrade reboot ``` __Настраиваем локаль__ Правим конфиг локалей `nano /etc/default/locale` ``` @@ -64,4 +66,11 @@ LC_TYPE=en_US.UTF-8 ``` dpkg-reconfigure locales reboot ``` __Ставим необходимые утилиты__ ``` sudo apt install -y htop git curl wget unzip zip mc iftop screen ```  - 
        
zmts revised this gist
Apr 4, 2020 . No changes.There are no files selected for viewing
 - 
        
zmts revised this gist
Apr 4, 2020 . 1 changed file with 34 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Первичная настойка Debian Linux/Разворачиваем серверную инфраструктуру на Digital ocean Для проектов среднего и небольшого размера не всегда оправданно использовать AWS/Kubernetes подобную технологию. Для проектов нуждающихся в нескольких серверах отлично подходит Digital ocean. Который к тому же предоставляет средства вертикального скейлинга(увеличение производительной мощности уже существующих серверов). @@ -19,7 +19,7 @@ adduser superuser usermod -aG root superuser ``` Добавляем публичный SSH ключ для `superuser` на удаленный сервер. И если в проекте несколько серверов, дабы не создавать сертификат для каждого, можем переиспользовать его на каждом из серверов. То есть проделываем данную процедуру для каждого сервера. ``` ssh-copy-id -i /Users/alex/.ssh/myproject_test.pub [email protected] ``` @@ -30,7 +30,38 @@ ssh-copy-id -i /Users/alex/.ssh/myproject_test.pub [email protected] ssh -i /Users/alex/.ssh/myproject_test [email protected] ``` `nano /etc/ssh/sshd_config` - Запрещаем логинится по паролю - Запрещаем руту ходить по ssh - Меняем дефолтный ssh порт ``` PasswordAuthentication no PermitRootLogin no Port 2222 ``` ``` sudo service ssh restart ``` Теперь можно приступить к остальной настройке системы. __Загрузить и установить последние обновления системы__ ``` apt update && apt upgrade reboot ``` __Настраиваем локаль__ Правим конфиг локалей `nano /etc/default/locale` ``` LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LC_TYPE=en_US.UTF-8 ``` Реконфигурируем локали (из списка выбираем en_US.utf8 и ru_RU.utf8, далее по умолчанию ставим en_US.utf8) ``` dpkg-reconfigure locales reboot ```  - 
        
zmts revised this gist
Apr 4, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,7 +25,7 @@ ssh-copy-id -i /Users/alex/.ssh/myproject_test.pub [email protected] ``` Теперь публичный ключ размещен на сервере в файле `/home/superuser/.ssh/authorized_keys` Логинимся через сертификат ``` ssh -i /Users/alex/.ssh/myproject_test [email protected] ```  - 
        
zmts created this gist
Apr 4, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ # Разворачиваем серверную инфраструктуру на Digital ocean Для проектов среднего и небольшого размера не всегда оправданно использовать AWS/Kubernetes подобную технологию. Для проектов нуждающихся в нескольких серверах отлично подходит Digital ocean. Который к тому же предоставляет средства вертикального скейлинга(увеличение производительной мощности уже существующих серверов). ## SSH cертификат Создаем сертификат под которым будем логинится на сервера нашего проекта (на локальной машине) ``` ssh-keygen -t rsa -b 4096 -f /Users/alex/.ssh/myproject_test -C "myproject comment" ``` Не забываем сделать его бекап ## Процедура создания сервера(дроплета) - Создаем новый Droplet (one-time password) - Логинимся под рутом - Создаем пользователя(`superuser`) под которым мы в дальнейшем будем ходить по SSH ``` adduser superuser usermod -aG root superuser ``` Добавляем публичный SSH ключ для superuser на удаленный сервер ``` ssh-copy-id -i /Users/alex/.ssh/myproject_test.pub [email protected] ``` Теперь публичный ключ размещен на сервере в файле `/home/superuser/.ssh/authorized_keys` - Логинимся через сертификат ``` ssh -i /Users/alex/.ssh/myproject_test [email protected] ``` Запрещаем руту ходить по ssh `nano /etc/ssh/sshd_config` ``` PermitRootLogin no ```