Uncategorised
- Информация о материале
- Автор: Павел
- Категория: Uncategorised
- Просмотров: 255
обновление clamav в 2024
#!/bin/bash
systemctl stop clamav-freshclam
rm -rf /var/lib/clamav/*
wget http://unlix.ru/clamav/main.cvd -O /var/lib/clamav/main.cvd
wget http://unlix.ru/clamav/daily.cvd -O /var/lib/clamav/daily.cvd
wget http://unlix.ru/clamav/bytecode.cvd -O /var/lib/clamav/bytecode.cvd
systemctl start clamav-freshclam
0 0 * * 0 root /hoem/update_clamav.sh
- Информация о материале
- Автор: Павел
- Категория: Uncategorised
- Просмотров: 161
nexcloud при стандартной установки не хватает пакетов
nano /etc/php/8.2/cli/php.ini
или
nano /etc/php/8.3/cli/php.ini
вписываем параметр
apc.enable_cli=1
а потом сверху ставим доппакеты
apt install php-memcache php-memcached php8.2-memcache php-apcu php8.2-apcu php8.2-imagick php8.2-gmp php8.2-bcmath php8.2-redis
apt install php-memcache php-memcached php8.3-memcache php-apcu php8.3-apcu php8.3-imagick php8.3-gmp php8.3-bcmath php8.3-redis
Добавляем в файл
nano /var/www/cloud/config/config.php
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'redis' =>
array (
'host' => '127.0.0.1',
'port' => 6379,
),
'defaultapp' => 'files',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'memcache.local' => '\\OC\\Memcache\\APCu',
'installed' => true,
/etc/init.d/apache2 restart
- Информация о материале
- Автор: Павел
- Категория: Uncategorised
- Просмотров: 153
2 шаблона для debian ubuntu
- Информация о материале
- Автор: Павел
- Категория: Uncategorised
- Просмотров: 206
proxmox ansible-playbook автоматизируем создание и запуск VM
создаем проект/папку и пусть называется pma vm create и создаем файлы с именами, создаваемые файлы я выделил жирным
ansible.cfg
[defaults]
host_key_checking = false
inventory = ./hosts.ini
private_key_file = /root/.ssh/id_rsa
create_template.sh
#!/bin/bash
# завершить выполнение, если некоторая команда, которая не является частью какого-либо теста (например, if [ ... ] или конструктора &&), возвращает ненулевой код
set -e
# проверка запуска скрипта с параметром
if [ -n "$1" ]; then
vm_passwd="$1"
else
echo "Необходимо указать желаемый пароль для шаблона первым аргументом"
exit 1
fi
# задаём необходимые переменные
cloudimg=noble-server-cloudimg-amd64.img
img_url=https://cloud-images.ubuntu.com/noble/current/
# параметры вм
vm_id=200
vm_name="ubuntu-2404-cloudinit-template"
vm_memory=2024
vm_cores=4
vm_user=pavel
# данные proxmox
px_storage=local
px_bridge=vmbr0
# проверить наличие образа, если его нет - скачать образ ubuntu server 20.04 с поддержкой cloud-init
if [ ! -f "$cloudimg" ]; then
echo "Файл $cloudimg не существует"
echo Скачиваю образ Ubuntu Server 24.04 с поддержкой cloud-init
wget $img_url/$cloudimg
fi
echo Создаю ВМ
qm create $vm_id --name $vm_name --memory $vm_memory --cores $vm_cores --net0 virtio,bridge=$px_bridge
qm importdisk $vm_id $cloudimg $px_storage
qm set $vm_id --virtio0 $px_storage:$vm_id/vm-$vm_id-disk-0.raw
qm set $vm_id --boot c -bootdisk virtio0
qm set $vm_id --ide2 $px_storage:cloudinit
qm set $vm_id --serial0 socket --vga serial0
qm set $vm_id --cipassword=$vm_passwd --ciuser=$vm_user
qm set $vm_id --agent 1
qm resize $vm_id virtio0 +8G
echo Конвертирую ВМ в шаблон
qm template $vm_id
echo Удаляю ранее скачанный образ
rm focal-server-cloudimg-amd64.img
echo Готово
exit 0
create_vm.yaml
---
- name: Настройка окружения
hosts: proxmox
vars_files:
- vars.yaml
- vms.yaml
tasks:
- name: Клонирование ВМ из шаблона
community.general.proxmox_kvm:
node: "{{ node }}"
name: "{{ item.value.name }}"
newid: "{{ item.value.vmid }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
api_host: "{{ api_host }}"
clone: "{{ clone_vm }}"
storage: "{{ pve_storage }}"
format: qcow2
timeout: 500
loop: "{{ q('dict', vms) }}"
- name: Настройка IP адресов
command: "qm set {{ item.value.vmid }} --ipconfig0 gw={{ item.value.gw }},ip={{ item.value.ip }}"
loop: "{{ q('dict', vms) }}"
- name: Настройка DNS
command: "qm set {{ item.value.vmid }} --nameserver {{ item.value.dns }}"
loop: "{{ q('dict', vms) }}"
- name: Копирование SSH ключей в ВМ
command: "qm set {{ item.value.vmid }} --sshkey {{ key_name }}"
args:
chdir: ~/.ssh
loop: "{{ q('dict', vms) }}"
- name: Обновление параметров ВМ
community.general.proxmox_kvm:
api_host: "{{ api_host }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
cores: "{{ item.value.cores }}"
sockets: "{{ item.value.sockets }}"
memory: "{{ item.value.memory }}"
update: true
vmid: "{{ item.value.vmid }}"
node: "{{ node }}"
name: "{{ item.value.name }}"
loop: "{{ q('dict', vms) }}"
- name: Запуск ВМ
community.general.proxmox_kvm:
api_host: "{{ api_host }}"
api_password: "{{ api_password }}"
api_user: "{{ api_user }}"
vmid: "{{ item.value.vmid }}"
node: "{{ node }}"
state: started
loop: "{{ q('dict', vms) }}"
hosts.ini
[proxmox]
pve ansible_host=10.10.50.254 ansible_user=root
vars.yaml
pve_storage: VM
api_host: 10.10.50.254
api_user: root@pam
api_password: veryVerIPas$vordS
node: pve01
clone_vm: ubuntu-2404-cloudinit-template
key_name: id_rsa.pub
vms.yaml
vms:
us1:
name: 02.smolpharm.com
ip: 10.10.50.222/24
gw: 10.10.50.1
dns: 8.8.8.8
vmid: 222
cores: 4
sockets: 1
memory: 2048
После всех манипуляций, запустим скрипт
sh create_template.sh password-users
после данной команды скачается образ ubuntu и с него сделается шаблон для создания и запуска ВМ
Далее запускай ansible
ansible-playbook create_vm.yaml
ansible-playbook create_vm.yaml
PLAY [Настройка окружения] ************************************************************************************************************************************************************************************
TASK [Gathering Facts] ****************************************************************************************************************************************************************************************
ok: [pve]
TASK [Клонирование ВМ из шаблона] *****************************************************************************************************************************************************************************
changed: [pve] => (item={'key': 'us1', 'value': {'name': '02.smolpharm.com', 'ip': '10.10.50.222/24', 'gw': '10.10.50.1', 'dns': '8.8.8.8', 'vmid': 222, 'cores': 4, 'sockets': 1, 'memory': 2048}})
TASK [Настройка IP адресов] ***********************************************************************************************************************************************************************************
changed: [pve] => (item={'key': 'us1', 'value': {'name': '02.smolpharm.com', 'ip': '10.10.50.222/24', 'gw': '10.10.50.1', 'dns': '8.8.8.8', 'vmid': 222, 'cores': 4, 'sockets': 1, 'memory': 2048}})
TASK [Настройка DNS] ******************************************************************************************************************************************************************************************
changed: [pve] => (item={'key': 'us1', 'value': {'name': '02.smolpharm.com', 'ip': '10.10.50.222/24', 'gw': '10.10.50.1', 'dns': '8.8.8.8', 'vmid': 222, 'cores': 4, 'sockets': 1, 'memory': 2048}})
TASK [Копирование SSH ключей в ВМ] ****************************************************************************************************************************************************************************
changed: [pve] => (item={'key': 'us1', 'value': {'name': '02.smolpharm.com', 'ip': '10.10.50.222/24', 'gw': '10.10.50.1', 'dns': '8.8.8.8', 'vmid': 222, 'cores': 4, 'sockets': 1, 'memory': 2048}})
TASK [Обновление параметров ВМ] *******************************************************************************************************************************************************************************
changed: [pve] => (item={'key': 'us1', 'value': {'name': '02.smolpharm.com', 'ip': '10.10.50.222/24', 'gw': '10.10.50.1', 'dns': '8.8.8.8', 'vmid': 222, 'cores': 4, 'sockets': 1, 'memory': 2048}})
TASK [Запуск ВМ] **********************************************************************************************************************************************************************************************
changed: [pve] => (item={'key': 'us1', 'value': {'name': '02.smolpharm.com', 'ip': '10.10.50.222/24', 'gw': '10.10.50.1', 'dns': '8.8.8.8', 'vmid': 222, 'cores': 4, 'sockets': 1, 'memory': 2048}})
PLAY RECAP ****************************************************************************************************************************************************************************************************
pve : ok=7 changed=6 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Все, ВМ создалась и запустилась
- Информация о материале
- Автор: Павел
- Категория: Uncategorised
- Просмотров: 182
openvpn debian 12 install
wget -P ~/ https://github.com/OpenVPN/easy-rsa/releases/download/v3.1.7/EasyRSA-3.1.7.tgz
cd ~
ls
tar xvf EasyRSA-3.1.7.tgz
cd ~/EasyRSA-3.1.7/
cp vars.example vars
./easyrsa init-pki
./easyrsa build-ca nopass
ls
cd ..
cd EasyRSA-3.1.7/
./easyrsa init-pki
./easyrsa gen-req server nopass
cp ~/EasyRSA-3.1.7/pki/private/server.key /etc/openvpn/
cp /root/EasyRSA-3.1.7/pki/reqs/server.req /tmp
ls
./easyrsa import-req /tmp/server.req server
./easyrsa sign-req server server
cp /root/EasyRSA-3.1.7/pki/issued/server.crt /tmp
cp pki/ca.crt /tmp
cp /tmp/{server.crt,ca.crt} /etc/openvpn/
./easyrsa gen-dh
openvpn --genkey --secret ta.key
ls
cp ta.key /etc/openvpn/
cp pki/dh.pem /etc/openvpn/
mkdir -p ~/client-configs/keys
chmod -R 700 ~/client-configs
./easyrsa gen-req client1 nopass
cp pki/private/client1.key ~/client-configs/keys/
cp pki/reqs/client1.req /tmp
./easyrsa import-req /tmp/client1.req client1
./easyrsa sign-req client client1
cp pki/issued/client1.crt /tmp
./easyrsa sign-req client client1
cp pki/issued/client1.crt /tmp
cp /tmp/client1.crt ~/client-configs/keys/
cp ~/EasyRSA-3.1.7/ta.key ~/client-configs/keys/
cp /etc/openvpn/ca.crt ~/client-configs/keys/
cp /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz /etc/openvpn/
cp /usr/share/doc/openvpn/examples/sample-config-files/server.conf /etc/openvpn/
ip route | grep default
systemctl start openvpn@server
systemctl status openvpn@server
ip addr show tun0
systemctl enable openvpn@server
mkdir -p ~/client-configs/files
cp /usr/share/doc/openvpn/examples/sample-config-files/client.conf ~/client-configs/base.conf
##############################################
# Sample client-side OpenVPN 2.0 config file #
# for connecting to multi-client server. #
# #
# This configuration can be used by multiple #
# clients, however each client should have #
# its own cert and key files. #
# #
# On Windows, you might want to rename this #
# file so it has a .ovpn extension #
##############################################
# Specify that we are a client and that we
# will be pulling certain config file directives
# from the server.
client
# Use the same setting as you are using on
# the server.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
;dev tap
dev tun
# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel
# if you have more than one. On XP SP2,
# you may need to disable the firewall
# for the TAP adapter.
;dev-node MyTap
# Are we connecting to a TCP or
# UDP server? Use the same setting as
# on the server.
;proto tcp
proto udp
# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.
remote skid.skid.su 1194
;remote my-server-2 1194
# Choose a random host from the remote
# list for load-balancing. Otherwise
# try hosts in the order specified.
;remote-random
# Keep trying indefinitely to resolve the
# host name of the OpenVPN server. Very useful
# on machines which are not permanently connected
# to the internet such as laptops.
resolv-retry infinite
# Most clients don't need to bind to
# a specific local port number.
nobind
# Downgrade privileges after initialization (non-Windows only)
user nobody
group nogroup
# Try to preserve some state across restarts.
persist-key
persist-tun
# If you are connecting through an
# HTTP proxy to reach the actual OpenVPN
# server, put the proxy server/IP and
# port number here. See the man page
# if your proxy server requires
# authentication.
;http-proxy-retry # retry on connection failures
;http-proxy [proxy server] [proxy port #]
# Wireless networks often produce a lot
# of duplicate packets. Set this flag
# to silence duplicate packet warnings.
;mute-replay-warnings
# SSL/TLS parms.
# See the server config file for more
# description. It's best to use
# a separate .crt/.key file pair
# for each client. A single ca
# file can be used for all clients.
#ca ca.crt
#cert client.crt
#key client.key
# Verify server certificate by checking that the
# certificate has the correct key usage set.
# This is an important precaution to protect against
# a potential attack discussed here:
# http://openvpn.net/howto.html#mitm
#
# To use this feature, you will need to generate
# your server certificates with the keyUsage set to
# digitalSignature, keyEncipherment
# and the extendedKeyUsage to
# serverAuth
# EasyRSA can do this for you.
remote-cert-tls server
# If a tls-auth key is used on the server
# then every client must also have the key.
#tls-auth ta.key 1
# Select a cryptographic cipher.
# If the cipher option is used on the server
# then you must also specify it here.
# Note that v2.4 client/server will automatically
# negotiate AES-256-GCM in TLS mode.
# See also the data-ciphers option in the manpage
cipher AES-256-CBC
auth SHA256
key-direction 1
# Enable compression on the VPN link.
# Don't enable this unless it is also
# enabled in the server config file.
#comp-lzo
# Set log file verbosity.
verb 3
# Silence repeating messages
;mute 20
nano ~/client-configs/make_config.sh
#!/bin/bash
# First argument: Client identifier
KEY_DIR=~/client-configs/keys
OUTPUT_DIR=~/client-configs/files
BASE_CONFIG=~/client-configs/base.conf
cat ${BASE_CONFIG} \
<(echo -e '<ca>') \
${KEY_DIR}/ca.crt \
<(echo -e '</ca>\n<cert>') \
${KEY_DIR}/${1}.crt \
<(echo -e '</cert>\n<key>') \
${KEY_DIR}/${1}.key \
<(echo -e '</key>\n<tls-auth>') \
${KEY_DIR}/ta.key \
<(echo -e '</tls-auth>') \
> ${OUTPUT_DIR}/${1}.ovpn
chmod 700 ~/client-configs/make_config.sh
cd ~/client-configs
./make_config.sh pavel
ls ~/client-configs/files
./make_config.sh client1
