Compare commits
19 Commits
gitea-draf
...
607719e7d9
| Author | SHA1 | Date | |
|---|---|---|---|
| 607719e7d9 | |||
| bf18fa9a3c | |||
| 00eff22bf5 | |||
| dd447678ad | |||
| b066e85b29 | |||
| fb4781f3ae | |||
| eada80734a | |||
| 265d6d5ce7 | |||
| ec2b6e13b7 | |||
| 07f4c78355 | |||
| fbea0bc085 | |||
| fc76f14fca | |||
| f7031b96ea | |||
| 19ec4e82f3 | |||
| a9a446d8b7 | |||
| 7db0de6eda | |||
| db68076181 | |||
| c0b936f792 | |||
| dd903276f7 |
@@ -1,3 +1,3 @@
|
|||||||
Просто склад моих заметок доступный всем.
|
Просто склад моих заметок, доступный всем.
|
||||||
|
|
||||||
Можно предлагать правки и дополнения на [GitHub](https://github.com/Arity-T/knowledge-base).
|
Можно предлагать правки и дополнения на [GitHub](https://github.com/Arity-T/knowledge-base).
|
||||||
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
`ctrl + shift + p` - главное сочетание клавиш, которое стоит запомнить.
|
`ctrl + shift + p` - главное сочетание клавиш, которое стоит запомнить.
|
||||||
|
|
||||||
|
`alt + 1/2/3/...` - переключение между открытыми вкладками в порядке их расположения.
|
||||||
|
|
||||||
Удалить множественные курсоры можно с помощью `Esc`.
|
Удалить множественные курсоры можно с помощью `Esc`.
|
||||||
|
|
||||||
Если с помощью `ctrl + d` выделили лишнее, то сочетанием `ctrl + u` можно убрать последнее выделение.
|
Если с помощью `ctrl + d` выделили лишнее, то сочетанием `ctrl + u` можно убрать последнее выделение.
|
||||||
@@ -21,3 +23,30 @@
|
|||||||
|
|
||||||
`alt + z` - крайне полезно при работе с Latex, Markdown и другими "широкими" файлами.
|
`alt + z` - крайне полезно при работе с Latex, Markdown и другими "широкими" файлами.
|
||||||
|
|
||||||
|
`ctrl + j` - скрыть/показать нижнюю панель (терминал, логи и т.д.).
|
||||||
|
|
||||||
|
`alt + shift + r` - показать файл, выбранный в левой панели с файлами, в проводнике.
|
||||||
|
|
||||||
|
`ctrl + shift + .` - breadcrumbs
|
||||||
|
|
||||||
|
## Кастомные сочетания клавиш
|
||||||
|
|
||||||
|
Сочетания клавиш для быстрого создания папок и файлов через проводник внутри VS Code.
|
||||||
|
|
||||||
|
- `a` - создать файл.
|
||||||
|
- `shift + a` - создать папку.
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"key": "a",
|
||||||
|
"command": "explorer.newFile",
|
||||||
|
"when": "filesExplorerFocus && !inputFocus"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "shift+a",
|
||||||
|
"command": "explorer.newFolder",
|
||||||
|
"when": "filesExplorerFocus && !inputFocus"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
@@ -1,86 +1,196 @@
|
|||||||
# Кастомизация Gitea
|
# Кастомизация Gitea
|
||||||
|
|
||||||
```sh
|
Во всех командах подразумевается, что Gitea [установлена из бинарника](https://docs.gitea.com/installation/install-from-binary) и [запускается как `systemd` сервис](https://docs.gitea.com/installation/linux-service).
|
||||||
sudo su - git
|
|
||||||
cd /var/lib/gitea/custom
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh
|
В документации есть страница, посвящённая [кастомизации Gitea](https://docs.gitea.com/administration/customizing-gitea).
|
||||||
mkdir -p /var/lib/gitea/custom/public/css
|
|
||||||
mkdir -p /var/lib/gitea/custom/templates/custom
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo nano /var/lib/gitea/custom/templates/custom
|
|
||||||
```
|
|
||||||
|
|
||||||
```html
|
## Свой `css`
|
||||||
<link rel="stylesheet" href="/custom/css/custom.css">
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh
|
Добавляем ссылку на свой файл со стилями.
|
||||||
sudo -u git mkdir css
|
|
||||||
sudo -u git nano css/custom.css
|
|
||||||
```
|
|
||||||
|
|
||||||
|
=== "Терминал"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Путь по умолчанию
|
||||||
|
export GITEA_CUSTOM=/var/lib/gitea/custom
|
||||||
|
|
||||||
|
sudo -u git mkdir -p $GITEA_CUSTOM/templates/custom
|
||||||
|
sudo -u git nano $GITEA_CUSTOM/templates/custom/header.tmpl
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "header.tmpl"
|
||||||
|
|
||||||
|
```html
|
||||||
|
<link rel="stylesheet" href="/assets/css/custom.css">
|
||||||
|
```
|
||||||
|
|
||||||
|
Создаём файл со стилями.
|
||||||
|
|
||||||
|
=== "Терминал"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo -u git mkdir -p $GITEA_CUSTOM/public/assets/css
|
||||||
|
sudo -u git nano $GITEA_CUSTOM/public/assets/css/custom.css
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "Пример custom.css"
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Стили для git.tishenko.dev */
|
||||||
|
* {
|
||||||
|
transition: all 0.125s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Список переменных и их значения по умолчанию
|
||||||
|
*
|
||||||
|
* Для светлой темы
|
||||||
|
* https://github.com/go-gitea/gitea/blob/main/web_src/css/themes/theme-gitea-light.css
|
||||||
|
*
|
||||||
|
* Для тёмной темы
|
||||||
|
* https://github.com/go-gitea/gitea/blob/main/web_src/css/themes/theme-gitea-dark.css
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Переопределения переменных для светлой и тёмной темы одновременно */
|
||||||
|
:root {
|
||||||
|
/* Основной цвет */
|
||||||
|
--color-primary: #6674c4;
|
||||||
|
--color-primary-contrast: #ffffff;
|
||||||
|
|
||||||
|
/* https://maketintsandshades.com/#4051B5 */
|
||||||
|
--color-primary-dark-1: #7985cb;
|
||||||
|
--color-primary-dark-2: #8c97d3;
|
||||||
|
--color-primary-dark-3: #a0a8da;
|
||||||
|
--color-primary-dark-4: #b3b9e1;
|
||||||
|
--color-primary-dark-5: #c6cbe9;
|
||||||
|
--color-primary-dark-6: #d9dcf0;
|
||||||
|
--color-primary-dark-7: #eceef8;
|
||||||
|
|
||||||
|
--color-primary-light-1: #5362bc;
|
||||||
|
--color-primary-light-2: #4051b5;
|
||||||
|
--color-primary-light-3: #3a49a3;
|
||||||
|
--color-primary-light-4: #334191;
|
||||||
|
--color-primary-light-5: #2d397f;
|
||||||
|
--color-primary-light-6: #26316d;
|
||||||
|
--color-primary-light-7: #20295b;
|
||||||
|
|
||||||
|
--color-primary-alpha-10: #6674c419;
|
||||||
|
--color-primary-alpha-20: #6674c433;
|
||||||
|
--color-primary-alpha-30: #6674c44b;
|
||||||
|
--color-primary-alpha-40: #6674c466;
|
||||||
|
--color-primary-alpha-50: #6674c480;
|
||||||
|
--color-primary-alpha-60: #6674c499;
|
||||||
|
--color-primary-alpha-70: #6674c4b3;
|
||||||
|
--color-primary-alpha-80: #6674c4cc;
|
||||||
|
--color-primary-alpha-90: #6674c4e1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Переопределения переменных для светлой темы */
|
||||||
|
@media (prefers-color-scheme: light) {
|
||||||
|
:root {}
|
||||||
|
|
||||||
|
#navbar-logo {
|
||||||
|
padding: 5px !important;
|
||||||
|
background: #14151A;
|
||||||
|
}
|
||||||
|
|
||||||
|
#navbar-logo img {
|
||||||
|
width: 27px !important;
|
||||||
|
height: 27px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#navbar-logo:hover {
|
||||||
|
background: #14151A !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Переопределения переменных для тёмной темы */
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
/* Шапка */
|
||||||
|
--color-nav-bg: #14151A;
|
||||||
|
--color-secondary-nav-bg: #14151A;
|
||||||
|
--color-nav-text: #BEC1C6;
|
||||||
|
--color-nav-hover-bg: #272A35;
|
||||||
|
|
||||||
|
/* Тёмно-серый фон основной */
|
||||||
|
--color-body: #1E2129;
|
||||||
|
|
||||||
|
--color-input-background: #14151A;
|
||||||
|
--color-menu: #14151A;
|
||||||
|
--color-card: #14151A;
|
||||||
|
--color-button: #14151A;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Перезапускаем Gitea.
|
||||||
```sh
|
```sh
|
||||||
sudo systemctl restart gitea
|
sudo systemctl restart gitea
|
||||||
```
|
```
|
||||||
|
|
||||||
|
После изменения стилей, страницу в браузере нужно обновить с помощью `ctrl + f5`.
|
||||||
|
|
||||||
|
## Настройка `app.ini`
|
||||||
|
|
||||||
|
Перечень всех возможных настроек представлен в [документации](https://docs.gitea.com/administration/config-cheat-sheet).
|
||||||
|
|
||||||
|
=== "Терминал"
|
||||||
|
```sh
|
||||||
|
sudo nano /etc/gitea/app.ini
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "Пример параметров app.ini"
|
||||||
|
```ini
|
||||||
|
[server]
|
||||||
|
LANDING_PAGE = explore
|
||||||
|
|
||||||
|
[other]
|
||||||
|
SHOW_FOOTER_VERSION = false
|
||||||
|
SHOW_FOOTER_TEMPLATE_LOAD_TIME = false
|
||||||
|
SHOW_FOOTER_POWERED_BY = false
|
||||||
|
ENABLE_FEED = false
|
||||||
|
|
||||||
|
[i18n]
|
||||||
|
LANGS = en-US,ru-RU
|
||||||
|
NAMES = English,Русский
|
||||||
|
|
||||||
|
[repository]
|
||||||
|
DISABLE_STARS = true
|
||||||
|
|
||||||
|
[cron]
|
||||||
|
ENABLED = true
|
||||||
|
|
||||||
|
[ui.meta]
|
||||||
|
AUTHOR = Artem Tishenko: Personal Git Repository Hub
|
||||||
|
DESCRIPTION = A personal hub for managing Git repositories by Artem Tishenko.
|
||||||
|
KEYWORDS = Artem Tishenko, Artyom Tishchenko, Git, self-hosted, personal projects, repositories, Gitea
|
||||||
|
```
|
||||||
|
|
||||||
|
Перезапускаем Gitea.
|
||||||
```sh
|
```sh
|
||||||
sudo nano /etc/gitea/app.ini
|
sudo systemctl restart gitea
|
||||||
```
|
|
||||||
https://docs.gitea.com/administration/customizing-gitea
|
|
||||||
https://docs.gitea.com/administration/config-cheat-sheet
|
|
||||||
|
|
||||||
```ini title="app.ini"
|
|
||||||
[server]
|
|
||||||
LANDING_PAGE = explore
|
|
||||||
|
|
||||||
[other]
|
|
||||||
SHOW_FOOTER_VERSION = false
|
|
||||||
SHOW_FOOTER_TEMPLATE_LOAD_TIME = false
|
|
||||||
SHOW_FOOTER_POWERED_BY = false
|
|
||||||
ENABLE_FEED = false
|
|
||||||
|
|
||||||
[i18n]
|
|
||||||
LANGS = en-US,ru-RU
|
|
||||||
NAMES = English,Русский
|
|
||||||
|
|
||||||
[repository]
|
|
||||||
DISABLE_STARS = true
|
|
||||||
|
|
||||||
[ui.meta]
|
|
||||||
AUTHOR = Artem Tishenko: Personal Git Repository Hub
|
|
||||||
DESCRIPTION = A personal hub for managing Git repositories by Artem Tishenko.
|
|
||||||
KEYWORDS = Artem Tishenko, Artyom Tishchenko, Git, self-hosted, personal projects, repositories, Gitea
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Изменение шаблонов страниц
|
||||||
|
|
||||||
|
Ищем шаблон для нужной версии в [репозитории Gitea](https://github.com/go-gitea/gitea/tree/main/templates), загружаем с помощью `wget` по такому же пути в `$GITEA_CUSTOM/templates` и редактируем.
|
||||||
|
|
||||||
|
Так, например, можно убрать пункт "Помощь" с ссылкой на `https://docs.gitea.com` из основного меню.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
mkdir -p /var/lib/gitea/custom/templates/base
|
# Путь по умолчанию
|
||||||
cd /var/lib/gitea/custom/templates/base
|
export GITEA_CUSTOM=/var/lib/gitea/custom
|
||||||
# перейти туда
|
|
||||||
wget https://raw.githubusercontent.com/go-gitea/gitea/refs/tags/v1.22.3/templates/base/footer_content.tmpl
|
|
||||||
|
|
||||||
# remove help - https://docs.gitea.com
|
# gitea --version
|
||||||
# remove explore - explore.repos
|
export GITEA_VERSION=v1.22.3
|
||||||
# remove sign_in (just visit /user/login)
|
|
||||||
wget https://github.com/go-gitea/gitea/raw/refs/tags/v1.22.3/templates/base/head_navbar.tmpl
|
|
||||||
|
|
||||||
|
sudo -u git mkdir -p $GITEA_CUSTOM/templates/base
|
||||||
mkdir -p /var/lib/gitea/custom/templates/repo
|
wget -P $GITEA_CUSTOM/templates/base https://raw.githubusercontent.com/go-gitea/gitea/refs/tags/$GITEA_VERSION/templates/base/head_navbar.tmpl
|
||||||
cd /var/lib/gitea/custom/templates/repo
|
sudo -u git nano $GITEA_CUSTOM/templates/base/head_navbar.tmpl
|
||||||
# remove packages
|
|
||||||
# remove wiki
|
|
||||||
# remove repo.activity
|
|
||||||
# remove repo.issues
|
|
||||||
# remove repo.pulls
|
|
||||||
# remove watch, fork
|
|
||||||
wget https://raw.githubusercontent.com/go-gitea/gitea/refs/tags/v1.22.3/templates/repo/header.tmpl
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Перезапускаем Gitea.
|
||||||
```sh
|
```sh
|
||||||
# <a class="item" href="https://kb.tishenko.dev/" target="_blank">Knowledge base</a>
|
sudo systemctl restart gitea
|
||||||
/var/lib/gitea/custom/templates/custom/extra_links.tmpl
|
|
||||||
```
|
```
|
||||||
@@ -1,5 +1,24 @@
|
|||||||
# Заметка о Powershell
|
# Заметка о Powershell
|
||||||
|
|
||||||
|
## Установка Powershell
|
||||||
|
|
||||||
|
По умолчанию в Windows установлен устаревший Windows PowerShell. Установить новый Powershell можно по [инструкции в репозитории](https://github.com/PowerShell/PowerShell?tab=readme-ov-file#get-powershell).
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
winget search Microsoft.PowerShell
|
||||||
|
winget install --id Microsoft.PowerShell --source winget
|
||||||
|
```
|
||||||
|
|
||||||
|
Затем стоит [установить PowerShell как профиль по умолчанию](https://stackoverflow.com/a/75891592/17341937).
|
||||||
|
|
||||||
|
Чтобы VSCode использовал PowerShell в качестве профиля по умолчанию, нужно добавить в `settings.json` следующий параметр:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"terminal.integrated.defaultProfile.windows": "PowerShell"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Мой Powershell profile
|
## Мой Powershell profile
|
||||||
|
|
||||||
Открыть файл настроек Powershell:
|
Открыть файл настроек Powershell:
|
||||||
@@ -12,12 +31,14 @@ code $profile # или notepad $profile
|
|||||||
# Лучше заменить настоящим wget
|
# Лучше заменить настоящим wget
|
||||||
# https://eternallybored.org/misc/wget/
|
# https://eternallybored.org/misc/wget/
|
||||||
# Скачать EXE для 64-bit и добавить в папку в PATH
|
# Скачать EXE для 64-bit и добавить в папку в PATH
|
||||||
remove-item alias:wget
|
# Удалять алиас нужно только в Windows PowerShell
|
||||||
|
# remove-item alias:wget
|
||||||
|
|
||||||
# Заменяем Invoke-WebRequest нормальным curl
|
# Заменяем Invoke-WebRequest нормальным curl
|
||||||
# Скачиваем curl for 64-bit тут https://curl.se/windows/
|
# Скачиваем curl for 64-bit тут https://curl.se/windows/
|
||||||
# Из папки bin архива переносим curl.exe в папку в PATH
|
# Из папки bin архива переносим curl.exe в папку в PATH
|
||||||
remove-item alias:curl
|
# Удалять алиас нужно только в Windows PowerShell
|
||||||
|
# remove-item alias:curl
|
||||||
|
|
||||||
# Алиасы
|
# Алиасы
|
||||||
new-alias actvenv venv/Scripts/activate
|
new-alias actvenv venv/Scripts/activate
|
||||||
@@ -28,8 +49,11 @@ function crtvenv {
|
|||||||
actvenv
|
actvenv
|
||||||
}
|
}
|
||||||
|
|
||||||
function python-path {
|
# Аналог команды which в Linux
|
||||||
python -c "import sys; print(sys.executable)"
|
# https://stackoverflow.com/a/16949127/17341937
|
||||||
|
function which($name)
|
||||||
|
{
|
||||||
|
Get-Command $name | Select-Object -ExpandProperty Definition
|
||||||
}
|
}
|
||||||
|
|
||||||
# Модуль для автокомплита GIT https://github.com/dahlbyk/posh-git
|
# Модуль для автокомплита GIT https://github.com/dahlbyk/posh-git
|
||||||
|
|||||||
14
docs/python/django.md
Normal file
14
docs/python/django.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
## Отслеживание SQL запросов
|
||||||
|
|
||||||
|
```python
|
||||||
|
from django.db import connection, reset_queries
|
||||||
|
|
||||||
|
# Сбрасываем счетчик запросов
|
||||||
|
reset_queries()
|
||||||
|
|
||||||
|
# Код, который работает с БД
|
||||||
|
|
||||||
|
# Теперь выводим все запросы, которые были зафиксированы
|
||||||
|
for query in connection.queries:
|
||||||
|
print(query)
|
||||||
|
```
|
||||||
83
docs/servers/grafana.md
Normal file
83
docs/servers/grafana.md
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
|
||||||
|
## Запуск Prometheus с помощью systemd
|
||||||
|
|
||||||
|
Ссылку на последнюю версию `Prometheus` можно найти на [странице загрузок](https://prometheus.io/download/).
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Скачиваем и распаковываем релиз
|
||||||
|
wget <link>
|
||||||
|
tar xvf prometheus-*.*-amd64.tar.gz
|
||||||
|
cd prometheus-*.*
|
||||||
|
|
||||||
|
# Создаём отдельного пользователя и группу для запуска prometheus
|
||||||
|
sudo adduser --system --no-create-home --group prometheus
|
||||||
|
|
||||||
|
# Конфиг
|
||||||
|
sudo mkdir /etc/prometheus
|
||||||
|
sudo cp prometheus.yml /etc/prometheus/
|
||||||
|
sudo chown -R prometheus:prometheus /etc/prometheus
|
||||||
|
|
||||||
|
# Папка для данных
|
||||||
|
sudo mkdir /var/lib/prometheus
|
||||||
|
sudo chown -R prometheus:prometheus /var/lib/prometheus
|
||||||
|
|
||||||
|
# Бинарники prometheus и promtool
|
||||||
|
sudo cp prometheus /usr/local/bin/
|
||||||
|
sudo chown prometheus:prometheus /usr/local/bin/prometheus
|
||||||
|
sudo cp promtool /usr/local/bin/
|
||||||
|
sudo chown prometheus:prometheus /usr/local/bin/promtool
|
||||||
|
```
|
||||||
|
|
||||||
|
Создаём `systemd` сервис. Список возможных параметров запуска `Prometheus` представлен в [документации](https://prometheus.io/docs/prometheus/latest/command-line/prometheus/).
|
||||||
|
|
||||||
|
|
||||||
|
=== "Терминал"
|
||||||
|
```sh
|
||||||
|
sudo nano /etc/systemd/system/prometheus.service
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "prometheus.service"
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[Unit]
|
||||||
|
Description=Prometheus Server
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=prometheus
|
||||||
|
Group=prometheus
|
||||||
|
Restart=on-failure
|
||||||
|
ExecStart=/usr/local/bin/prometheus \
|
||||||
|
--config.file=/etc/prometheus/prometheus.yml \
|
||||||
|
--storage.tsdb.path=/var/lib/prometheus \
|
||||||
|
--storage.tsdb.retention.size=500MB
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
```
|
||||||
|
|
||||||
|
Добавляем `Prometheus` в автозагрузку и запускаем.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable prometheus
|
||||||
|
sudo systemctl start prometheus
|
||||||
|
sudo systemctl status prometheus
|
||||||
|
```
|
||||||
|
|
||||||
|
При обновлении конфига, нужно будет перезапустить сервис.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo systemctl restart prometheus
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Node Exporter
|
||||||
|
|
||||||
|
Устанавливаем `Node Exporter` по инструкции из [документации](https://prometheus.io/docs/guides/node-exporter/). Сервис в `systemd` для `Node Exporter` будет создан автоматически.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo systemctl status node_exporter.service
|
||||||
|
```
|
||||||
|
|
||||||
|
[Пример](https://grafana.com/grafana/dashboards/1860-node-exporter-full/) дашборда `Grafana` для `Node Exporter`.
|
||||||
24
docs/servers/misc.md
Normal file
24
docs/servers/misc.md
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Разное
|
||||||
|
|
||||||
|
## Поиск по истории команд в bash
|
||||||
|
|
||||||
|
Включаем поиск по истории команд `bash` по префиксу.
|
||||||
|
|
||||||
|
=== "Терминал"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
nano ~/.inputrc
|
||||||
|
```
|
||||||
|
|
||||||
|
=== ".inputrc"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
"\e[A": history-search-backward
|
||||||
|
"\e[B": history-search-forward
|
||||||
|
```
|
||||||
|
|
||||||
|
После обновления `.inputrc` нужно либо начать сеанс заново, либо выполнить команду.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
bind -f ~/.inputrc
|
||||||
|
```
|
||||||
@@ -1,10 +1,41 @@
|
|||||||
|
## Добавление сайта
|
||||||
|
|
||||||
|
Создаём конфиг.
|
||||||
|
|
||||||
|
=== "Терминал"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo nano /etc/nginx/sites-available/new-site.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "Пример конфига"
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
server {
|
||||||
|
server_name example.com www.example.com;
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
root /var/www/new-site;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ =404;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Активируем конфиг.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo ln -s /etc/nginx/sites-available/new-site.conf /etc/nginx/sites-enabled/
|
||||||
|
sudo systemctl reload nginx.service
|
||||||
|
```
|
||||||
|
|
||||||
## SSL-сертификат с certbot
|
## SSL-сертификат с certbot
|
||||||
|
|
||||||
!!! tip "Актуальная версия Python"
|
!!! tip "Актуальная версия Python"
|
||||||
|
|
||||||
Обычно системый `Python` достаточно старый. Для установки `certbot` может потребоваться более новая версия. Минимальные требования можно узнать на [pypi](https://pypi.org/project/certbot/).
|
Обычно системный `Python` достаточно старый. Для установки `certbot` может потребоваться более новая версия. Минимальные требования можно узнать на [pypi](https://pypi.org/project/certbot/).
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo apt update
|
sudo apt update
|
||||||
@@ -33,6 +64,17 @@ SSL-сертификат получается и устанавливается
|
|||||||
# Автообновление сертификатов
|
# Автообновление сертификатов
|
||||||
echo "0 0,12 * * * root /opt/certbot/bin/python -c 'import random; import time; time.sleep(random.random() * 3600)' && sudo certbot renew -q" | sudo tee -a /etc/crontab > /dev/null
|
echo "0 0,12 * * * root /opt/certbot/bin/python -c 'import random; import time; time.sleep(random.random() * 3600)' && sudo certbot renew -q" | sudo tee -a /etc/crontab > /dev/null
|
||||||
```
|
```
|
||||||
|
??? tip "Отключение UFW"
|
||||||
|
|
||||||
|
Может потребоваться временно отключить UFW.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo ufw disable
|
||||||
|
|
||||||
|
# Получаем сертификат
|
||||||
|
|
||||||
|
sudo ufw enable
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Несколько полезных команд.
|
Несколько полезных команд.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ ssh root@<IPv4>
|
|||||||
```sh { .code-wrap }
|
```sh { .code-wrap }
|
||||||
# Создаём пользователя и наделяем правом использовать `sudo`.
|
# Создаём пользователя и наделяем правом использовать `sudo`.
|
||||||
adduser <user>
|
adduser <user>
|
||||||
adduser <username> sudo
|
adduser <user> sudo
|
||||||
|
|
||||||
# Переключаемся на нового пользователя
|
# Переключаемся на нового пользователя
|
||||||
su - <user>
|
su - <user>
|
||||||
@@ -156,7 +156,7 @@ sudo ufw status verbose
|
|||||||
|
|
||||||
## Настройка Fail2Ban
|
## Настройка Fail2Ban
|
||||||
|
|
||||||
[Fail2Ban](https://github.com/fail2ban/fail2ban) - базовая защита сервера от brute-force аттак.
|
[Fail2Ban](https://github.com/fail2ban/fail2ban) - базовая защита сервера от brute-force атак.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo apt update
|
sudo apt update
|
||||||
49
docs/servers/ssh.md
Normal file
49
docs/servers/ssh.md
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
# Заметка по SSH
|
||||||
|
|
||||||
|
## SSH-agent
|
||||||
|
|
||||||
|
### Установка на Windows
|
||||||
|
|
||||||
|
`ssh-agent` является частью OpenSSH. Начиная с Windows 10, OpenSSH устанавливается вместе с системой, однако службу `ssh-agent` надо включить вручную. Для этого нужно запустить `Powershell` от имени администратора и выполнить несколько команд.
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
Set-Service -Name ssh-agent -StartupType Automatic
|
||||||
|
Start-Service ssh-agent
|
||||||
|
```
|
||||||
|
|
||||||
|
Проверить состояние `ssh-agent` можно с помощью команды.
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
Get-Service -Name ssh-agent | select -property status,name,starttype
|
||||||
|
```
|
||||||
|
|
||||||
|
На Windows `git` по умолчанию использует свою службу `ssh` вместо системной, поэтому `ssh-agent` не будет с ним работать и пароли всё равно придётся вводить вручную. Однако можно настроить `git` так, чтобы он использовал системный `ssh`.
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
git config --global core.sshCommand "C:/Windows/System32/OpenSSH/ssh.exe"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Использование
|
||||||
|
|
||||||
|
!!! warning "Security warning"
|
||||||
|
|
||||||
|
На Windows доступ к ключам сохраняется даже после перезагрузки системы.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Добавляет ключи из ~/.ssh/
|
||||||
|
ssh-add
|
||||||
|
# Можно указать путь
|
||||||
|
ssh-add path/to/id_rsa
|
||||||
|
# Список добавленных ключей
|
||||||
|
ssh-add -l
|
||||||
|
# Удалить все ключи из памяти агента
|
||||||
|
ssh-add -D
|
||||||
|
```
|
||||||
|
|
||||||
|
Иногда нужно, чтобы при подключении на сервер, были доступны приватные ключи из локального `ssh-agent`. Для этого можно использовать команду `ssh -A`.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ssh -A user@server
|
||||||
|
```
|
||||||
|
|
||||||
|
Либо указать `ForwardAgent yes` в конфиге `ssh`.
|
||||||
@@ -37,7 +37,7 @@ theme:
|
|||||||
icon: material/brightness-4
|
icon: material/brightness-4
|
||||||
name: Switch to light mode
|
name: Switch to light mode
|
||||||
extra:
|
extra:
|
||||||
generator: false
|
# generator: false
|
||||||
social:
|
social:
|
||||||
- icon: fontawesome/brands/github
|
- icon: fontawesome/brands/github
|
||||||
link: https://github.com/Arity-T
|
link: https://github.com/Arity-T
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
mkdocs
|
mkdocs
|
||||||
|
pymdownx
|
||||||
|
mkdocs-material
|
||||||
mkdocs-glightbox
|
mkdocs-glightbox
|
||||||
Reference in New Issue
Block a user