ssh-keygen -i -f ssh2.pub
Category: tech
Using chroot
--rbind
, some subdirectories of dev/
and sys/
will not be unmountable. Attempting to unmount with umount -l
in this situation will break your session, requiring a reboot. If possible, use -o bind
instead.In the following example, /location/of/new/root
is the directory where the new root resides.
First, mount the temporary API filesystems:
# cd /location/of/new/root # mount -t proc /proc proc/ # mount -t sysfs /sys sys/ # mount --rbind /dev dev/
And optionally:
# mount --rbind /run run/
If you are running a UEFI system, you will also need access to EFI variables. Otherwise, when installing GRUB, you will receive a message similar to: UEFI variables not supported on this machine
:
# mount --rbind /sys/firmware/efi/efivars sys/firmware/efi/efivars/
Next, in order to use an internet connection in the chroot environment, copy over the DNS details:
# cp /etc/resolv.conf etc/resolv.conf
Finally, to change root into /location/of/new/root
using a bash shell:
# chroot /location/of/new/root /bin/bash
chroot: cannot run command '/usr/bin/bash': Exec format error
, it is likely that the architectures of the host environment and chroot environment do not match.chroot: '/usr/bin/bash': permission denied
, remount with the execute permission:mount -o remount,exec /location/of/new/root
.
After chrooting, it may be necessary to load the local bash configuration:
# source /etc/profile # source ~/.bashrc
# export PS1="(chroot) $PS1"
When finished with the chroot, you can exit it via:
# exit
Then unmount the temporary file systems:
# cd / # umount --recursive /location/of/new/root
umount: /path: device is busy
, this usually means that either: a program (even a shell) was left running in the chroot or that a sub-mount still exists. Quit the program and use findmnt -R /location/of/new/root
to find and then umount
sub-mounts. It may be tricky to umount
some things and one can hopefully have umount --force
work. As a last resort, use umount --lazy
which just releases them. In either case to be safe, reboot
as soon as possible if these are unresolved to avoid possible future conflicts.VIM registers
Registers in Vim let you run actions or commands on text stored within them. To access a register, you type "a before a command, where a is the name of a register.
If you want to copy the current line into register k, you can type
"kyy
Or you can append to a register by using a capital letter
"Kyy
You can then move through the document and paste it elsewhere using
"kp
To paste from system clipboard on Linux
"+p
To paste from system clipboard on Windows (or from "mouse highlight" clipboard on Linux)
"*p
To access all currently defined registers type
:reg
Conver heic to jpg in linux
https://github.com/monostream/tifig/releases
find . -type f -iname '*.heic' -exec tifig -v -q 100 -i '{}' -o '{}.jpg' \; find . -type f -iname '*.heic' -delete find . -type f -iname '*.heic'
Old Jira color codes
Upgrade from 7.2.4 to 7.13 break my eyes.
This colors uses in old Jira:
Header Background Color #205081
Header Highlight Background Color #296CA3
Header Separator Color #2E3D54
Header Text Color #ffffff
Header Text Highlight Color #f0f0f0
Menu Item Highlight Background Color #3b73af
Menu Item Highlight Text Color #ffffff
Button Background Color #3b7fc4
Button Text Color, #ffffff
Link Active Color #3b73af
Heading Color #292929
Link Color #3b73af
Gadget Colors
Color 1 (Default) #3b73af
Color 2 #d04437
Color 3 #ea632b
Color 4 #14892c
Color 5 #205081
Color 6 #654982
Color 7 #707070
find regex egrep
find . -type f -regex '.*\.php\|.*\.htm*' -exec egrep -l "yandex|metrica" {} \;
sync: Сколько осталось данных в кеше
watch grep -e Dirty: -e Writeback: /proc/meminfo
Удаление всех аудиозаписей VK
var script=document.createElement("script");script.src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js",script.type="text/javascript",document.getElementsByTagName("head")[0].appendChild(script);
function a(){b=$(document).find("._audio_row__action_delete").first(),b.length?($(document).find("._audio_row__action_delete").each(function(){$(this).trigger("click")}),$("html, body").animate({scrollTop:$(document).height()},0),setTimeout(function(){a()},500)):alert("ГОТОВО! Alexander Sergeev 2016")}a();
vsftpd + virtual users
apt-get install libpam-mysql
anonymous_enable=NO local_enable=YES guest_enable=YES use_localtime=YES local_root=/home/vsftpd/$USER secure_chroot_dir=/var/run/vsftpd chroot_local_user=YES xferlog_enable=YES pam_service_name=vsftpd hide_ids=YES user_sub_token=$USER dirmessage_enable=YES local_umask=022 connect_from_port_20=YES write_enable=YES virtual_use_local_privs=YES
auth required pam_mysql.so user=vsftpd passwd=p455w0rd host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=2 account required pam_mysql.so user=vsftpd passwd=p455w0rd host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=2
create database vsftpd; use vsftpd; CREATE TABLE `accounts` ( -> `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , -> `username` VARCHAR( 30 ) NOT NULL , -> `pass` VARCHAR( 50 ) NOT NULL , -> UNIQUE ( -> `username` -> ) -> ) ENGINE = MYISAM ; GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON vsftpd.* TO 'vsftpd'@'localhost' IDENTIFIED BY 'X0Bih4vtIbzgLPd9AxLM'; FLUSH PRIVILEGES; INSERT INTO accounts (username, pass) VALUES('testuser', PASSWORD('testpasswd'));
mkdir -p /home/vsftpd/testuser/www chmod a-w /home/vsftpd/testuser /etc/init.d/vsftpd restart
Avahi and Unicast Domains .local
mDNS/DNS-SD is inherently incompatible with unicast DNS zones .local. We strongly recommend not to use Avahi or nss-mdns in such a network setup. N.B.: nss-mdns is not typically bundled with Avahi and requires a separate download and install.
Background: The Zeroconf protocols Avahi implements are known as mDNS and DNS-SD. mDNS (short for Multicast DNS) is based on traditional (unicast) DNS, but the two systems do not interact. mDNS is used to manage a special cooperative zone .local where all local mDNS servers can freely register host names or services. Before mDNS was introduced the domain .local was sometimes used in non-public (unicast) DNS servers to assign names in LANs. Unfortunately some networks still use this domain that way. If Avahi and nss-mdns is installed properly a machine does not contact a unicast DNS server when resolving names from the .local domain, thus the unicast DNS domain .local becomes unreachable.
If you come across a network where .local is a unicast DNS domain, please contact the local administrator and ask him to move his DNS zone to a different domain. If this is not possible, we recommend not to use Avahi in such a network at all.
Workarounds
If you really want to use Avahi with .local as unicast domain, you might want to try the following. YMMV. Don't come running to us if something doesn't work as expected. It's your own fault!
The recommended nss-mdns configuration line for /etc/nsswitch.conf is
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
This makes nss-mdns authoritative for .local.
If this is changed as follows, unicast DNS will be tried before mDNS for .local, essentially "merging" the unicast and the multicast domain .local, with unicast taking precedence.
hosts: files dns mdns4
Please note that this line will "unbreak" the name service switch (NSS, aka gethostbyname()) only. Avahi itself will still not resolve any hosts from a unicast domain .local. i.e. this change will make some things work, but not all.
Please remember, that we do no recommend using nss-mdns in this way. Why? Firstly, because the conflict resolution protocol of mDNS becomes ineffective. Secondly, because due to the "merging" of theses zones, DNS RRs might point to wrong other RRs. Thirdly, this can become a security issue, because information about the mDNS domain .local which is intended to be link-local might leak into the Internet. Fourthly, when you mistype host names from .local the long mDNS timeout will always occur. Fifthly it creates more traffic than necessary. And finally it is really ugly.
Better workaround
If you want to use avahi in this environment, instead of asking the administrator to move the .local zone (for example, this is the default for a Small Business Server environment on Windows) then simply modify your /etc/avahi/avahi-daemon.conf with the following entry:
domain-name=.alocal
Avahi will simply use the domain .alocal to do its magic.
Distributors
If you are a distributor, please follow the following recommendations when packaging Avahi/nss-mdns:
We recommend to run a special script at bootup and whenever the DNS configuration changes (i.e. from the DHCP hook script), which checks if there is a zone .local on the newly configured DNS server. If there is, please make sure to shut down Avahi and to disable nss-mdns. (Disabling nss-mdns explicitly is not necessary if it wasn't compiled with the mDNS mini stack, i.e. is not compiled with --enable-legacy). Use the bind9 host tool to check for such a zone:
#!/bin/sh if host -t SOA local. > /dev/null 2> /dev/null ; then # Hoho! There is a domain .local in unicast DNS! Let's disable Avahi! if test -x /etc/init.d/avahi ; then /etc/init.d/avahi stop > /dev/null 2> /dev/null if test -x /usr/bin/logger ; then logger -p daemon.warning -t avahi <<EOF Avahi detected that your currently configured local DNS server serves a domain .local. This is inherently incompatible with Avahi and thus Avahi disabled itself. If you want to use Avahi in this network, please contact your administrator and convince him to use a different DNS domain, since .local should be used exclusively for Zeroconf technology. For more information, see http://avahi.org/wiki/AvahiAndUnicastDotLocal EOF fi fi fi
Besides writing a warning about this to syslog, a notification bubble on the screen might also be advisable.