Total: 23
1 2 3 4 5
Ср, 21 февраля 2018, 13:49

nginx and letsencrypt locations

server {
    listen 80;
    server_name example.com;

    location / {
       return 301 https://$server_name$request_uri;
    }
   
    location /.well-known/acme-challenge/ {
      root /var/www/html;
    }
 }

 

 

Ср, 21 февраля 2018, 12:54

macOs / Linux ssh autocomplete hint

_complete_ssh_hosts ()
{
        COMPREPLY=()
        cur="${COMP_WORDS[COMP_CWORD]}"
        comp_ssh_hosts=`cat ~/.ssh/known_hosts | \
                        cut -f 1 -d ' ' | \
                        sed -e s/,.*//g | \
                        grep -v ^# | \
                        uniq | \
                        grep -v "\[" ;
                cat ~/.ssh/config | \
                        grep "^Host " | \
                        awk '{print $2}'
                `
        COMPREPLY=( $(compgen -W "${comp_ssh_hosts}" -- $cur))
        return 0
}


complete -F _complete_ssh_hosts ssh

 

Вт, 13 сентября 2016, 08:17

chroot ssh linux user

/etc/ssh/sshd_config: 

 

#Subsystem sftp /usr/lib/openssh/sftp-server

Subsystem sftp internal-sftp

 

Match group chrooted

    ChrootDirectory /www/sites

    X11Forwarding no

    AllowTcpForwarding no

    ForceCommand internal-sftp

 

/etc/passwd:

testuser:x:1002:1002::/www/sites/testuser:/usr/lib/sftp-server

 

Вт, 19 апреля 2016, 12:39

kvm live backup

Live backup of your VM running in KVM under Ubuntu using qcow2 disk images

 

# First of all disable apparmor to allow access

aa-status

aa-complain /usr/sbin/libvirtd

aa-complain /etc/apparmor.d/libvirt/libvirt-xxxxxxxxxxxxxxxxxx

 

# View disks

virsh domblklist test-backup

 

# Suspend the domain (This is optional. I do this so that the condition of virtual machines remains unchanged during the backup.)

virsh suspend test-backup

 

# Create snapshot

virsh snapshot-create-as --domain test-backup test-snap1 \

--diskspec vda,file=/home/virtual/test_backup/test-c.img \

--diskspec vdb,file=/home/virtual/test_backup/test-d.img \

--disk-only --atomic

# or

virsh snapshot-create-as --domain test-backup test-backup-snap1 --disk-only --atomic

 

# View snapshots

virsh snapshot-list test-backup

 

# View disks (it must be running on snapshots)

virsh domblklist test-backup

 

# Copy drives to backup dir

rsync -avh --progress drive-c.qcow2 export/drive-c.qcow2-copy

rsync -avh --progress drive-d.qcow2 export/drive-d.qcow2-copy

 

# Perform active blockcommit by live merging contents

virsh blockcommit test-backup vda --active --verbose --pivot

virsh blockcommit test-backup vdb --active --verbose --pivot

 

# View disks (it must be running on normal drives)

virsh domblklist test-backup

 

# Unsuspend the domain

virsh resume test-backup

 

# View snapshots again

virsh snapshot-list test-backup

 

# Delete snapshots

virsh snapshot-delete test-backup test-backup-snap1 --metadata

 

# View snapshots to check 

virsh snapshot-list test-backup

 

# Delete snapshot files

 

rm -f /home/virtual/test_backup/drive-c.test-backup-snap1

rm -f /home/virtual/test_backup/drive-d.test-backup-snap1

 

 

 

Total: 23
1 2 3 4 5