date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,628,980,198,000 |
I have an external USB disk with ext4 unencrypted:
/dev/sda1 3.6T 2.9T 613G 83% /data
I wish to encrypt this disk without losing data. I migrated this disk from Raspberry3 to Raspberry4, because of better performance I now wish to encrypt.
I read about Filesystem stacked level encryption and Block device-level encryption, but it seems LUKS the most secure and the Debian standard.
I read this guide:
WARNING! The following command will remove all data on the partition that you are encrypting. You WILL lose all your information! So make
sure you backup your data to an external source such as NAS or hard
disk before typing any one of the following commands.
# cryptsetup -y -v luksFormat /dev/xvdc
I can't copy the 4 TB data to another disk, because I have no disk with that much capacity.
How to encrypt this disk without backup/restore the existing data? Is it possible?
|
It's possible, but with all in-place conversions, there is a certain risk of data loss.
To make room for the LUKS header, unless you intend to use an external header, you must first shrink the filesystem (with resize2fs if it's ext4). For LUKS1, you should shrink it by 2MiB. For LUKS2, you can shrink it by 4M, 16M or up to 64M. If you intend to use advanced features (dm-integrity) you might have to shrink it even more.
Alternatively to shrinking, you could also make the partition larger, if the disk partition layout allows for that.
Encrypt existing data using the offline cryptsetup-reencrypt utility: (not installed by all distributions, might be in a separate package, otherwise grab from source)
# cryptsetup-reencrypt --new --type luks1 --reduce-device-size 2M /dev/sdXn
Enter new passphrase:
Verify passphrase:
[A wild progress bar appears.]
Using the online cryptsetup reencrypt for LUKS2:
# cryptsetup reencrypt --new --reduce-device-size 16M /dev/sdXn
WARNING!
========
This will overwrite data on LUKS2-temp-2c9761be-a765-4349-aa0a-553203e534f1.new irrevocably.
Are you sure? (Type uppercase yes):
Enter passphrase for LUKS2-temp-2c9761be-a765-4349-aa0a-553203e534f1.new:
Verify passphrase:
[A wild progress bar appears.]
So this works, provided no power or cable blips happened during the entire process.
As the cryptsetup-reencrypt man page puts it:
ALWAYS BE SURE YOU HAVE RELIABLE BACKUP BEFORE USING THIS TOOL.
| How to encrypt an external disk without backing-up/restoring the existing data? |
1,628,980,198,000 |
So I'm installing a new Arch with the document here for a whole system encryption.
The first part I get confused is here which the document wrote:
Warning: GRUB does not support LUKS2. Do not use LUKS2 on partitions that GRUB needs to access.
But in the later part of the section, it told me to run the command cryptsetup luksFormat /dev/sda3. But as I run it it ask for a password but doesn't it said GRUB doesn't support LUKS2?
Later I enter the password, go down through to grub installing which I run grub-mkconfig -o /boot/grub/grub.cfg and it said filaed to connect lvmetad, but since it's warning I ignored it.
Later I go through the process till the last part without getting any error.
But then I exit arch-chroot and reboot but it can't boot, it skipped to next OS (which is Windows 10 in my case), why? Which part did I get wrong? How to solve it?
P.S. Here is a table of my disk with command lsblk
NAME SIZE TYPE MOUNTPOINT
sda 114.6G disk
sda1 4G part
sda2 4G part /mnt/boot/efi
sda3 16G part
cryptboot 16G crypt /mnt/boot
sda4 90.6G part
lvm 90.6G crypt
AALEvol-swap 8G lvm [SWAP]
AALEvol-root 82.6G lvm /mnt
|
Create a partition on beginning of your Hard Disk Drive, it's size should be between 600 MB and 1GB, and in Linux setup mark that partition as /boot partition. You shouldn't encrypt the boot partition as none of your potentially sensitive data will be written to it.
If you want to wipe the entire Hard Disk Drive before re-partitioning, i suggest you use fdisk -l | more to list all your Hard Disk Drives and all partitions on them, then when you find the drive do
dd if=/dev/urandom of=/dev/sd(X) where X is your HDD letter.
Then create other partitions which will be encrypted: 1./SWAP, 2./ROOT and 3. /HOME (optional).
| Can't boot Arch Linux after installation with dm-crypt whole system encryption (BIOS) |
1,628,980,198,000 |
I have a triple boot setup (3xLinux). All Linuces share /home and swap, and their / partitions are next to each other. All reside in an LVM on LUKS:
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:0 0 951.8G 0 disk
|-nvme0n1p1 259:1 0 800M 0 part /boot/efi
|-nvme0n1p2 259:2 0 32G 0 part
|-nvme0n1p3 259:3 0 619M 0 part
`-nvme0n1p4 259:4 0 706.5G 0 part
`-cryptolvm 254:0 0 706.5G 0 crypt
|-cryptolvm-swap 254:1 0 32G 0 lvm [SWAP]
|-cryptolvm-home 254:2 0 430.0G 0 lvm /home
|-cryptolvm-centos 254:3 0 41G 0 lvm /mnt/centos
|-cryptolvm-arch 254:4 0 41G 0 lvm /
`-cryptolvm-opensuse 254:5 0 41G 0 lvm /mnt/opensuse
openSUSE manages the GRUB2 (with full encryption, i.e. disk unlock password needed before grub menu which resides on the openSUSE system partition /).
Problem: Arch does not unlock the cryptodisk /dev/nvme0n1p4 and therefore cannot access its / during boot. It drops me to an emergency prompt.
This is the setup an Arch Linux:
mkinitcpio configuration (and yes, I have re-created /boot/initramfs-linux.img after changing this):
# grep crypt /etc/mkinitcpio.conf | tail -1
HOOKS=(base udev autodetect modconf keyboard block encrypt lvm2 filesystems fsck)
GRUB2 configuration on openSUSE:
# grep --after=18 Arch /mnt/opensuse/boot/grub2/grub.cfg
menuentry 'Arch Linux (rolling) (on /dev/mapper/cryptolvm-arch)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' {
insmod part_gpt
insmod cryptodisk
insmod luks
insmod gcry_rijndael
insmod gcry_rijndael
insmod gcry_sha256
insmod lvm
insmod ext2
cryptomount -u 99999999999999999999999999999999
set root='lvmid/VVVVVV-VVVV-VVVV-VVVV-VVVV-VVVV-VVVVVV/qqqqqq-qqqq-qqqq-qqqq-qqqq-qqqq-qqqqqq'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint='lvmid/VVVVVV-VVVV-VVVV-VVVV-VVVV-VVVV-VVVVVV/qqqqqq-qqqq-qqqq-qqqq-qqqq-qqqq-qqqqqq' aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
else
search --no-floppy --fs-uuid --set=root aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
fi
linuxefi /boot/vmlinuz-linux cryptdevice=UUID=99999999999999999999999999999999:cryptolvm root=/dev/mapper/cryptolvm-arch resume=/dev/cryptolvm/swap splash=silent quiet showopts
initrdefi /boot/initramfs-linux.img
}
LVM devices:
# vgs -v
VG Attr Ext #PV #LV #SN VSize VFree VG UUID VProfile
cryptolvm wz--n- 4.00m 1 5 0 706.45g <120.51g VVVVVV-VVVV-VVVV-VVVV-VVVV-VVVV-VVVVVV
# lvs -v | grep arch
arch cryptolvm 1 -wi-ao---- <40.96g -1 -1 254 4 qqqqqq-qqqq-qqqq-qqqq-qqqq-qqqq-qqqqqq
Disk/partition UUIDs:
# blkid | egrep '(p4|arch)'
/dev/nvme0n1p4: UUID="99999999-9999-9999-9999-999999999999" TYPE="crypto_LUKS" PARTUUID="cccccccc-cccc-cccc-cccc-cccccccccccc"
/dev/mapper/cryptolvm-arch: UUID="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" PARTUUID="cccccccc-cccc-cccc-cccc-cccccccccccc"
Workaround:
GRUB2 (or initramfs) drops me to a prompt because it cannot mount /dev/mapper/cryptolvm-arch to / (or, to /new_root). So during each boot I enter manually:
> cryptsetup open /dev/nvme0n1p4 cryptolvm
(...)
> mount /dev/mapper/cryptolvm-arch /new_root
> ^D
Why is this necessary? The mount is given twice (cryptomount and cryptdevice) in grub.cfg (and this is indeed used).
EDIT:
Perhaps this has to do with EFI? Would I receive an EFI error if it were? openSUSE boots via EFI, chain-loads the grub.cfg from its /, then boots Arch - is linuxefi correct here?
Just before GRUB2 drops me to the emergency shell I can type keys and they appear on the screen. When the shell opens the typed characters are still in the buffer and are entered in that shell.
|
Start Your system with the rd.debug (init-ramdisk debug) kernel flag added. This should shed some light on what is going wrong.
If You have it You kan bost the last one or two screens with xtrace output if You cannot the the problem Yourself then.
You can also direct the output to files in addition (i.e. add rd.log=all flag to kernel options) and should be able to get the log as copyable and better scrollable text after boot finished.
And, what I forgot, in Your above snippets You anonymized for whatever reasons the UUID and I don't know what is Your original config, but You have forgoten the dashes.
Example from my system (the blkid is the command that is run to find the physical device from Your cryptdevice=UUID=21685fd6-f2e3-4037-8645-3957cff3568c:cryptolvm kernel option, the part between cryptodevice= up to the first colon will be searched with the below command):
[root@ArchTestVM ~]# blkid -lt "UUID=21685fd6-f2e3-4037-8645-3957cff3568c" -o device
/dev/nvme0n1p2
[root@ArchTestVM ~]# blkid -lt "UUID=21685fd6f2e3403786453957cff3568c" -o device
[root@ArchTestVM ~]#
| LVM on LUKS FDE: GRUB won't mount my root partition / during boot even though cryptomount and cryptdevice are given in grub.cfg |
1,628,980,198,000 |
I have an almost fresh Kali linux installation in an Hyper-V virtual machine. It is configured with hard disk encryption during installation.
After some working days, I reduced the amount of RAM memory reserved for the VM, but when I boot up the reconfigured machine, the password used to decrypt the hard drive is reported as invalid.
The reported error is:
cryptsetup: ERROR: sdaX_crypt: cryptsetup failed, bad password or options?
If I undo the configuration change the password is valid again...
Does exist a relation between the LUKS decryption algorithm and the machine memory size? It doesn't have sense, in my opinion.
Which can be the reason?
Thanks in advance.
|
LUKS2 by default uses the argon2 key derivation function which is so called memory hard -- it intentionally uses a lot of RAM (up to 1 GiB with cryptsetup) when unlocking the device to prevent brute force attacks on GPUs. Exact amount of RAM it requires depends on the amount of RAM you have when creating the LUKS device so if you reduce the amount of RAM later you won't be able to unlock it.
You can change it using cryptsetup luksChangeKey <device> (which is usually used to change the password but it also allows changing the key derivation function) either with --pbkdf-memory <RAM in kilobytes> to lower the argon2 required memory or with --pbkdf pbkdf2 to use the older PBKDF2 key derivation function that doesn't use memory at all.
| Linux Hard drive encryption password invalid after memory size change |
1,628,980,198,000 |
I have a strange problem I don't understand.
I have a Kubuntu 19.04 installation that has a guided install of an encrypted LVM root.
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465,8G 0 disk
└─sda1 8:1 0 465,8G 0 part
sdb 8:16 0 223,6G 0 disk
├─sdb1 8:17 0 731M 0 part /boot
├─sdb2 8:18 0 1K 0 part
└─sdb5 8:21 0 222,9G 0 part
└─sdb5_crypt 253:0 0 222,9G 0 crypt
├─kubuntu--vg-root 253:1 0 221,9G 0 lvm /
└─kubuntu--vg-swap_1 253:2 0 980M 0 lvm [SWAP]
sdb is a SSD and sda a HDD.
sda is just a mass storage of unimportant data and not encrypted.
cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/mapper/kubuntu--vg-root / ext4 errors=remount-ro 0 1
# /boot was on /dev/sdb1 during installation
UUID=5502e3df-bf98-4ec3-9277-0b2d22308be2 /boot ext4 defaults 0 2
/dev/mapper/kubuntu--vg-swap_1 none swap sw 0 0
with
/dev/sda1: UUID="86b8c281-dc71-4102-92b5-070843eb2784" TYPE="ext4" PARTUUID="998890db-01"
/dev/sdb1: UUID="5502e3df-bf98-4ec3-9277-0b2d22308be2" TYPE="ext4" PARTUUID="4b7c5ebc-01"
/dev/sdb5: UUID="85e69429-53aa-4348-83d9-cb2b68128ec4" TYPE="crypto_LUKS" PARTUUID="4b7c5ebc-05"
/dev/mapper/sdb5_crypt: UUID="ysVfBL-KvGw-tce2-g1ko-5cUu-ichc-31kfCO" TYPE="LVM2_member"
/dev/mapper/kubuntu--vg-root: UUID="8995e215-a95b-499c-b83d-a12987e20600" TYPE="ext4"
/dev/mapper/kubuntu--vg-swap_1: UUID="72f9eb33-6d0e-4f86-9c3e-d1eb5e83aa63" TYPE="swap"
So imho everything should be fine if I demount sda, which is 86b8c281-dc71-4102-92b5-070843eb2784.
But if I do this, the system does not boot.
In fact, if I look into my BIOS/UEFI, in reality I boot from the HDD and not the SSD.
If I change the boot device to the SSD or demount the HDD, nothing happens (besides a blinking underscore on the top left screen were I cannot read/write anything)
Does anybody have an idea what is (or I understand) wrong here?
Additional info:
cat /etc/crypttab
sdb5_crypt UUID=85e69429-53aa-4348-83d9-cb2b68128ec4 none luks,discard
|
The syntax of the PARTUUID values indicates your disks are probably using MBR partitioning and classic BIOS-style boot. And the symptoms suggest that your bootloader is actually written onto sda rather than sdb, even though your /boot partition is sdb1. This is because in BIOS-based systems, the OS installer cannot necessarily tell in which order BIOS will see the disks, and will generally assume that the first detected disk (sda) is the disk the BIOS will boot the system from.
When you remove sda, you're left with no functional MBR-based bootloader, and unfortunately your system BIOS fails to give you a good error message for that.
Assuming that you're using the default GRUB bootloader, it's embedded into the actual Master Boot Record and in the space between MBR and the beginning of the first partition. So it's not a regular file and cannot be moved or otherwise manipulated as one.
However, this is fairly easy to fix.
First, you should edit the /boot/grub/device.map file to say:
(hd0) /dev/sdb
This will tell the GRUB installation tool (that you'll soon be using): "When installing a new instance of GRUB, assume that the disk that is currently sdb will be the first detected disk on the system." This is important because we're preparing to remove sda from the system.
Once the file is successfully modified, you should run:
sudo grub-install /dev/sdb
This will not do any harm to your existing GRUB instance, but will write a new one to sdb.
Now you should be able to remove the sda disk, and still have the system boot normally.
Since the original sda disk is now removed, the sdb disk will probably appear as sda, unless Kubuntu has a mechanism to persist disk device names (in which case you'll probably find the record associating the name sdb to the disk at /etc/udev/rules.d/). So you should edit the /boot/grub/device.map again to match the new system state (or just remove the file altogether):
(hd0) /dev/sda
This will be important if/when an update for GRUB is installed.
| Encrypted LVM not Booting When Demount unaffected HDD |
1,628,980,198,000 |
I tried to delete all files named "Thumbs.db" with something like
$ rm -rd /path/to/hdd/decrypted/folder/* --name Thumbs.db
but it just started deleting in alphabetical order. Now, I have to recover the files, which are still on the HDD, but
they're encrypted
and
I meanwhile shut down my computer and unplugged the hdd before.
Is there a way doing it?
I tried testdisk and photorec as stated in comments, which worked somehow for the not-first try.
But I'd like to have my files restored in the (sub)folders they've been, not just naked files themselves.
|
At first, you should never mount your disk read-write during the recovery.
Then you may copy the decrypted device (in /dev/mapper/foo-crypt) to an unencrypted device if you have some tools which only work with real disks. For usual linux utilities /dev/mapper/foo-crypt) should be okay.
Then testdisk and photorec are good choices and if you i.e. need some important text document you can even try with dd and grep cutting different parts of the image and trying to find the information.
The good news is, that most data probably is still there. The bad news is, that filenames and directory names often are gone, how much can be recovered depends on your filesystem. The classic windows approach was (with FAT32) to replace the first byte of the filename with 0, so the filenames were almost intact. ext2/3/4 destroys inodes completely as far as i know. So there you probably won't find such metadata, but tools like testdisk should be able to extract fileformats they know from the raw data in the partition.
You may be able to restore directory structure, if you find any files containing it. Look out for example for the locate(1) database, indexes of desktop search engines, recent files entries in gnome/kde/different programs, etc.
You probably will have to sort the restored files into the found directory structure yourself.
| How to rescue files after $ rm -rd ./* on encrypted, external HDD? |
1,628,980,198,000 |
Recently I added a new disk to my computer. I had a free SATA slot, so nothing else changed. A few days after the disk was inserted the computer stopped to boot.
I use Debian Bookworm. I have an encrypted partition which contains a LVM with several virtual partitions, including the root partition.
Usually after Grub I am prompted for the password of sda2_crypt. Now Grub passes, then the computer hangs for a while and I land in something I think is BusyBox telling me some command timed out. I tried to run sudo grub-mkconfig but it did not help.
I noticed that the boot fails only for a newer Kernel. Trying to boot the older kernel still works.
|
It turned out that by adding a second disk the drive letters changed. The disk containing the root file system was /dev/sda before but became /dev/sdb. This made it impossible for the system to decrypt the root partition.
Please note that Grub was fine, it loaded the Kernel correctly. Thus all attempts to repair the system targeting Grub were doomed to failure.
The shell that presented the error was a initramfs, not a BusyBox. It allows to to fix errors so the boot process can continue. A dedicated section in this answer explains how to do so.
Another section explains how to permanently fix the issue.
How to temporarily fix the issue in initramfs
Actually it is very simple. This answer has some more details but the steps regarding LVM were not necessary in my case.
What blocks the system to proceed to boot is that the device containing the root file system cannot be found. In my case this was /dev/mapper/ssd-root. For it to appear one has to manually open the encrypted partition:
cryptsetup open /dev/sdb2 some-arbitrary-mapname
After that, one must exit initramfs:
exit
Of course, one must use the device that contains the root file system. As map name, anything can be used. One could go with the generic sdb2_crypt, but one might choose to use a self-describing name like ssd500-crypt.
If one does not use the expected map name, e.g. sda2_crypt, one again will be prompted for a password some time later, again after a brief hang. The expected map name can be found in /etc/crypttab.
How to permanently fix the issue
In order to permanently fix the issue initramfs has to be updated. The following sequence of steps was used by the author:
Fix the issue temporarily in initramfs.
Change the map name in /etc/crypttab to something new. Anything goes, so one might use a self-describing value like ssd500-crypt.
sudo update-initramfs -u and reboot
Again temporarily resolve the issue in initramfs. However, this time the map name must be the one used at step (2).
sudo update-initramfs -u and reboot
Possibly step (1) can be omitted if the new map name is chosen there already.
| Full disk encryption stopped to boot a few days after adding a second disk |
1,628,980,198,000 |
I wanted to encrypt a flash drive but it didn't went well. Then I tried to remove the encryption but I am unable to do it.
Here is some info:
LUKS header information
Version: 2
Epoch: 4
Metadata area: 16384 [bytes]
Keyslots area: 16744448 [bytes]
UUID: 9f4cbeda-4733-4aa9-873f-764705300bee
Label: (no label)
Subsystem: (no subsystem)
Flags: (no flags)
Data segments:
0: crypt
offset: 16777216 [bytes]
length: (whole device)
cipher: aes-xts-plain64
sector: 512 [bytes]
Keyslots:
Tokens:
Digests:
0: pbkdf2
Hash: sha256
Iterations: 100669
Salt: 59 c1 f4 ec 5a d2 17 ae 9f 2a 06 73 9c c2 b8 8e
e8 02 0e 26 5c 8a 5a 33 a9 3e 98 ce 20 04 b8 c0
Digest: f2 f9 3b 7e 53 48 2b 24 05 4d c3 b9 42 4c 3b 1e
ef 8a 1f f5 22 85 25 de fc f9 e4 02 ac 0f 8b 9d
|
You cannot "remove" LUKS encryption AFAIK, you need to format/recreate your partition.
Steps to convert it back to a normal USB drive:
sudo unmount /mount/point
sudo cryptsetup close /dev/mapper/name
cat /dev/zero > /dev/device1
sudo mkfs.ext4 /dev/device1 (or mkfs.exfat/mkfs.vfat/mkfs.ntfs)
The cat command is not strictly necessary but really desired. If you don't run it you may discover files filled with random data.
mkfs.ext4 may refuse to run saying that there's data on the partition, in which case use the -F flag.
| Remove Cryptsetup LUKS encryption [duplicate] |
1,628,980,198,000 |
I'm trying to setup grub to boot from encrypted /boot on BTRFS based RAID1 array. However, I'm cannot find a way to force grub to unlock both disks. GRUB asks for key twice to unlock /boot, but I don't know how to ask it to unlock two cryptdevices after that. Here the boot process:
Unlock /dev/sda2:
Unlock /dev/sdb2:
grub asks for /dev/sdb2 password
and fails since /dev/mapper/root1 is not found
Here is how relevant parts of config files look like:
/etc/default/grub.cfg:
...
GRUB_CMDLINE_LINUX_DEFAULT="cryptdevice=/dev/sda2:root1 cryptkey=rootfs:/cryptfile.bin cryptdevice=/dev/sdb2:root2 cryptkey=rootfs:/cryptfile.bin root=/dev/mapper/root1 rootfstype=btrfs rootflags=device/dev/mapper/root1,device=/dev/mapper/root2,defaults"
GRUB_ENABLE_CRYPTODISK=y
...
Disk partitioning looks like:
/sda
/sda1 - SWAP
/sda2 - dmcrypt
/root1 - / (RAID1)
/sdb
/sdb1 - SWAP
/sdb2 - dmcrypt
/root2 - / (RAID1)
Any help please?
|
Working advice from reddit:
Find the encrypt boot hook (the one that is bundled inside your initramfs)
copy it and create encrypt2 from it. Remove some sanitation lines from it (like clearing some files or folders)
add encrypt2 to your hooks (mkinitcpio.conf(5)), encrypt2_* arguments to your kernel cmdline, rebuild the initramfs.
reboot?
| Grub with encrypted /boot and / on btrfs RAID1? |
1,628,980,198,000 |
In my root folder, it shows i only have 15 GB of space available. When opening Gparted, it shows an 950 gb encrypted partition. How come i only have 15GB available in my root directory?
Update: This question has already been answered, but i reworded it to better fit the community.
|
Your root partition is only 15G. The rest of the volume has not been allocated. Make another partition (using the mapped name of the encrypted disk) to access the rest of the disk.
https://wiki.archlinux.org/index.php/Disk_encryption#Block_device_encryption
| Wheres all my disk space? I encrypted a partition [closed] |
1,461,595,270,000 |
I have a problem with the wpa_supplicant program.
My problem is about the use of wpa_cli which needs wpa_supplicant. Error when I'm executing sudo wpa_cli:
Could not connect to wpa_supplicant
The manual start of wpa_supplicant gives me some errors:
sudo wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
rfkill: Cannot open RFKILL control device
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
wlan0: CTRL-EVENT-DISCONNECTED bssid=00:00:00:00:00:00 reason=0 ### NEW!!!
Config dhcp
## /etc/dhcp/dhcpd.conf
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.2 192.168.2.9;
option domain-name-servers 192.168.1.1;
option domain-name "home";
option routers 192.168.2.1;
}
Config wpa_supplicant
## /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
# network={
# ssid="__SSID__"
# key_mgmt=WPA-PSK
# psk="__PASS__"
# id_str="home"
# }
Config hostapd
## /etc/hostapd/hostapd.conf
interface=wlan0
driver=rtl871xdrv
ieee80211n=1
ssid=__SSID__
hw_mode=g
channel=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=__PASS__
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
# EDIT
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
Results of ifconfig / iwconfig
wlan0 Link encap:Ethernet HWaddr c0:4a:00:17:40:fd
inet adr:192.168.2.1 Bcast:192.168.2.255 Masque:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:14 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 lg file transmission:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wlan0 IEEE 802.11bgn ESSID:"__SSID__" Nickname:"<WIFI@REALTEK>"
Mode:Master Frequency:2.412 GHz Access Point: C0:4A:00:17:40:FD
Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Power Management:off
Link Quality=100/100 Signal level=0 dBm Noise level=0 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
How can I start wpa_supplicant without errors and have wpa_cli connect?
|
Finally, the written errors didn't affect the system.
My /etc/network/interfaces file looks like (only wlan part) :
iface wlan0 inet static
address 192.168.2.1
netmask 255.255.255.0
pre-up wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -B
With this config, I can use the sudo wpa_cli command without error !
Thanks to peterph anyway :) !
| WiFi error wpa_supplicant |
1,461,595,270,000 |
I have to connect to a WPA2 Enterprise network which only works if I don't verify the certificate. I would prefer not to do this, because this way anyone can see the MSCHAPv2 messages.
The first step to fixing this would be looking at the certificate offered by the AP, then configuring wpa_supplicant to only trust that one. But I don't know how to get the certificate. The wpa_cli "status" command doesn't show it and it's not in any logs.
I'm also curious about which SSL/TLS cipher suites are used. Is it possible to connect manually, maybe with openssl s_client?
|
You could use Wireshark to dump the handshake, then convert the binary data to PEM with openssl, as suggested by @grawity in a similar question at superuser:
Sadly, wpa_supplicant doesn't have an option to dump the certificates even in debug mode. (I'll update this if I find a better way.) You can still monitor the actual EAPOL authentication process, though. First, install Wireshark.
While disconnected, bring the interface up manually and start a capture on it:
$ sudo ip link set wlan0 up
$ wireshark -ki wlan0 &
Start wpa_supplicant and soon you'll see the TLS handshake:
The server will send its certificates immediately after ServerHello. Select the first such packet, then dig into:
802.1X
└─Extensible Authentication Protocol
└─Secure Sockets Layer
└─Handshake Protocol: Certificatte
└─Certificates
Right-click the first instance of "Certificate (stuff)" and choose "Export selected packet bytes". Wireshark will save it as a file, in binary DER format. Repeat this for all other certificates. The topmost one (RADIUS server's) has information that you can configure in altsubject_match; the last one (root CA) should be given to wpa_supplicant as ca_cert.
Now you have a few *.crt or *.der files in binary DER format. Convert them to PEM "text" format:
openssl x509 -inform DER < mycert.der > mycert.pem
(If your wpa_supplicant is using OpenSSL as the TLS handler, you must give it the "root CA" certificate; giving it the server's certificate won't work.
Note that it's also possible that the last certificate seen in Wireshark won't be of a root CA, but only issued by one of the root CAs in your /etc/ssl/certs directory... If that's the case, be sure to set altsubject_match as well – using public CAs would be insecure otherwise, since 802.1X unfortunately does not know what "hostname" to verify against, the way e.g. HTTPS would.)
| How to view the WPA2 PEAP certificate offered by an AP? |
1,461,595,270,000 |
tl;dr After reading the Arch wiki articles on installation, wireless setup and WPA supplicant, trying the suggestions below and a host of forum threads, I'm unable to get either of the following cards to connect to my wireless network when booting the Arch Linux 2013-09-01 ISO:
Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter (ID 7392:7811)
Realtek Semiconductor Corp. RTL8192CU 802.11n WLAN Adapter aka. Bolse® 300Mbps Wifi Wireless N USB Micro Mini Adapter (ID 0bda:8178)
Approach 1 (default):
The default way of doing this is supposed to be just systemctl stop dhcpcd.service followed by wifi-menu. It finds the network:
[SSID] + wpa 10
After a timeout it reports that the connection failed. If I run wifi-menu a second time it doesn't ask for a password, but when finished it finally gives some debug hints:
Job for netctl@wlp0s29f7u5\x2dBTHub4\x2dGRK6.service failed. See 'systemctl status netctl@wlp0s29f7u5\x2dBTHub4\x2dGRK6.service' and 'journalctl -xn' for details.
The former reports that the service is "loaded" but not "active" (literally inactive (dead)). The latter says:
WPA association/authentication failed for interface 'wlp0s29f7u5'
Does this mean the key in /etc/netctl/wlp0s29f7u5-BTHub4-GRK6 is wrong? I can't tell when programs want the actual Wi-Fi password and when they want something like the psk value from wpa_passphrase (man 5 netctl.profile doesn't say, for example).
Approach 2 (wpa_supplicant and wpa_passphrase as per deeraf and warl0ck's suggestions and the wiki page):
# echo 'ctrl_interface=/var/run/wpa_supplicant' > wifi.conf
# wpa_passphrase essid passphrase >> wifi.conf
# wpa_supplicant -B -i interface -c wifi.conf
Successfully initialized wpa_supplicant
# dhcpcd -A interface
[...]
timed out
exited
I tried connecting with iw directly, but got some strange output:
# iw dev wlp0s26f7u5 connect [SSID]
command failed: Operation not supported (-95)
|
It seems like the main problem is the BT Home Hub version 4 which came with the Internet subscription. After disabling 5 GHz wireless, WPS, 802.11 n, automatic channel selection and setting security to WPA2 only, I'm now able to get a connection within seconds in both Ubuntu and Windows, and a very sketchy connection (as in, ~30 seconds connectivity every few minutes with wpa_supplicant) with an up-to-date Arch Linux.
Update: After using NetworkManager (nmcli dev wifi connect SSID password PASSWORD) I am getting what seems like a little more stability - it still drops out every few minutes or so.
Windows also does not always get a connection for several minutes, after which it seems stable.
(I also tried connecting an old ADSL router, not realising that it cannot understand a VDSL signal.)
| How to connect to Wi-Fi network in Arch Linux? |
1,461,595,270,000 |
I'm trying to set the debug level of wpa_cli using the level command.
It doesn't matter if I use interactive mode or direct commands the level command always fails.
wpa_cli -i wlan0 level 1
=> FAIL
And interactive mode:
wpa_cli
wpa_cli v2.3
Copyright (c) 2004-2014, Jouni Malinen <[email protected]> and contributors
This software may be distributed under the terms of the BSD license.
See README for more details.
Selected interface 'wlan0'
Interactive mode
> level 5
FAIL
What is the correct way to get this to work?
I'm trying to get debug messages for when a connection fails (because of a wrong psk or something)
|
From the Interactive mode type log_level:
> log_level
Current level: INFO
Timestamp: 0
Then type log_level debug :
> log_level debug
OK
Verify using the command log_level :
> log_level
Current level: DEBUG
Timestamp: 0
| wpa_cli level command always fails |
1,461,595,270,000 |
I want to be sure that whatever string I pass into the line wpa-ssid "abc" in /etc/network/interfaces won't be used to break out of the configuration.
All I can find in the manual is that \ can be used at the end of a line to continue on the next line.
But what about \" in the middle of a line?
My worries is an SSID something like
A"
up rm -rf /\
Are there any general encoding that can be used for arbitrary characters into the SSID field?
|
In Debian's /etc/network/interfaces (or any other distribution using Debian's ifupdown utility), a backslash-newline sequence is removed, and backslash is not special anywhere else. A double quote character is not special either. The character # starts a comment if it's the first non-whitespace character on a (non-continuation) line. Null bytes are treated as newline characters (I think — the parser uses C strings and has no special handling for null bytes, so they might cause additional mischief).
Configuration lines take the form of an option name followed by a value, separated by whitespace. Leading and trailing whitespace is ignored. Some built-in options further parse the line into words; the value of options to iface always runs to the end of the line.
For example, the line
wpa-ssid "a b" "cd"
sets the option wpa-ssid to the 12-character string "a b" "cd" (internal whitespace is preserved).
WPA Supplicant's ifupdown script strips double quotes at the beginning and at the end of the wpa-ssid configuration string, the line above is equivalent to wpa-ssid a b" "cd. This way, you can have leading and trailing whitespace in the SSID.
I can't find a quoting issue in the WPA Supplicant ifupdown scripts, so it looks like anything that ifupdown will produce is safe.
Thus you can allow any string as an SSID to be injected into /etc/network/interfaces, provided that it does not contain any newline or null byte. Add double quotes around the string (if you don't, SSIDs with leading or trailing whitespace, or that end with \, or that begin or end with ", will be mangled).
| escape characters in /etc/network/interfaces |
1,461,595,270,000 |
When trying to connect to a network (specifically a WPA2 enterprise network for a university) with wpa_supplicant on Gentoo Linux, the network is shown as disabled when the flag is not set.
My wpa_supplicant.conf :
ctrl_interface=/var/run/wpa_supplicant
network={
ssid="TheNetwork"
eap=PEAP
identity="redacted"
password="redacted"
ca_cert="/etc/ssl/certs/AddTrust_External_Root.pem"
ca_path="/etc/ssl/certs/"
phase1="peapver=0"
phase2="auth=MSCHAPV2"
}
network={
ssid="Another network that works"
key_mgmt=NONE
disabled=1 # This is obviously not normally disabled
}
network={
ssid="Yet another working network"
psk="redacted"
disabled=1 # Likewise
}
Output of sudo wpa_supplicant -iwlp3s0 -c/etc/wpa_supplicant/wpa_supplicant.conf -d, with repetitive lines removed:
wpa_supplicant v2.6
random: Trying to read entropy from /dev/random
Successfully initialized wpa_supplicant
Initializing interface 'wlp3s0' conf '/etc/wpa_supplicant/wpa_supplicant.conf' driver 'default' ctrl_interface 'N/A' bridge 'N/A'
Configuration file '/etc/wpa_supplicant/wpa_supplicant.conf' -> '/etc/wpa_supplicant/wpa_supplicant.conf'
Reading configuration file '/etc/wpa_supplicant/wpa_supplicant.conf'
ctrl_interface='/var/run/wpa_supplicant'
Priority group 0
id=0 ssid='TheNetwork'
id=1 ssid='Another network that works'
id=2 ssid='Yet another working network'
nl80211: Supported cipher 00-0f-ac:1
...
nl80211: Supported cipher 00-0f-ac:9
nl80211: Using driver-based off-channel TX
nl80211: Driver-advertised extended capabilities (default) - hexdump(len=8): 00 00 00 00 00 00 00 40
nl80211: Driver-advertised extended capabilities mask (default) - hexdump(len=8): 00 00 00 00 00 00 00 40
nl80211: interface wlp3s0 in phy phy0
nl80211: Set mode ifindex 4 iftype 2 (STATION)
nl80211: Subscribe to mgmt frames with non-AP handle 0x55701974e5f0
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55701974e5f0 match=0104
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55701974e5f0 match=040a
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55701974e5f0 match=040b
...
rfkill: initial event: idx=1 type=1 op=0 soft=0 hard=0
netlink: Operstate: ifindex=4 linkmode=1 (userspace-control), operstate=5 (IF_OPER_DORMANT)
Add interface wlp3s0 to a new radio phy0
nl80211: Regulatory information - country=US (DFS-FCC)
nl80211: 2402-2472 @ 40 MHz 30 mBm
nl80211: 5170-5250 @ 80 MHz 23 mBm
nl80211: 5250-5330 @ 80 MHz 23 mBm (DFS)
nl80211: 5490-5730 @ 160 MHz 23 mBm (DFS)
nl80211: 5735-5835 @ 80 MHz 30 mBm
nl80211: 57240-63720 @ 2160 MHz 40 mBm
nl80211: Added 802.11b mode based on 802.11g information
wlp3s0: Own MAC address: [redacted]
wpa_driver_nl80211_set_key: ifindex=4 (wlp3s0) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0
...
wpa_driver_nl80211_set_key: ifindex=4 (wlp3s0) alg=0 addr=(nil) key_idx=5 set_tx=0 seq_len=0 key_len=0
wlp3s0: RSN: flushing PMKID list in the driver
nl80211: Flush PMKIDs
wlp3s0: No enabled networks (3 disabled networks)
wlp3s0: State: DISCONNECTED -> INACTIVE
ENGINE: Loading dynamic engine
ENGINE: Loading dynamic engine
EAPOL: SUPP_PAE entering state DISCONNECTED
EAPOL: Supplicant port status: Unauthorized
nl80211: Skip set_supp_port(unauthorized) while not associated
EAPOL: KEY_RX entering state NO_KEY_RECEIVE
EAPOL: SUPP_BE entering state INITIALIZE
EAP: EAP entering state DISABLED
Using existing control interface directory.
ctrl_iface bind(PF_UNIX) failed: Address already in use
ctrl_iface exists, but does not allow connections - assuming it was leftover from forced program termination
Successfully replaced leftover ctrl_iface socket '/var/run/wpa_supplicant/wlp3s0'
wlp3s0: Added interface wlp3s0
wlp3s0: State: INACTIVE -> DISCONNECTED
nl80211: Set wlp3s0 operstate 0->0 (DORMANT)
netlink: Operstate: ifindex=4 linkmode=-1 (no change), operstate=5 (IF_OPER_DORMANT)
random: Got 20/20 bytes from /dev/random
EAPOL: disable timer tick
What sticks out to me is the line wlp3s0: No enabled networks (3 disabled networks). This appears despite the fact that there are clearly only two disabled networks. Further evidence that the first network is being disabled despite the lack of a disabled=1 flag is that when running the wpa_supplement command with the other two networks enabled, a scan is performed and output, but all relevant APs are skipped as "disabled", "SSID mismatch", and "SSID mismatch", even though the SSIDs clearly do match. When running wpa_supplicant with the other two networks removed, the line wlp3s0: No enabled networks (1 disabled networks) appears.
What in the configuration is causing this to occur?
|
When you declare a network block in wpa_supplicant.conf, the default value for key_mgmt is WPA-PSK IEEE8021X (config.c sets to DEFAULT_KEY_MGMT, definition of DEFAULT_KEY_MGMT). Later on, when checking if a network is “disabled”, one of the checks is for whether the block has key_mgmt=WPA-PSK but does not have psk= set.
Thus, there are two issues with your network block.
wpa_supplicant will not even attempt to do PEAP authentication because you do not have key_mgmt=WPA-EAP. I was unable to test this myself, but you mentioned that setting this helped in the comments.
Since you are using the default value key_mgmt=WPA-PSK IEEE8021X, your block will be considered disabled because you have not set psk. Obviously, this second issue is not really something you care about because you intend to use PEAP ;-).
Based on wpa_supplicant-2.6.
| wpa_supplicant says network is disabled |
1,461,595,270,000 |
I installed a command-line QR-code generator:
apt install qrencode
I used the following format, so the QR scanner knows what to do with the content:
WIFI:T:WPA;S:<your Wi-Fi network name>;P:<your Wi-Fi network password>;;
generating the QR image file then works like this:
qrencode "WIFI:T:WPA;S:My_Network;P:My_very_secure_Password;;" -o wifi_login.png
this generates an image file wifi_login.png with the QR encoded string.
while the option -o FILENAME or --output=FILENAME makes qrencode write the generated image to this FILENAME. - can be used to print to standard output.
The whole procedure works pretty well with MAC devices, but not with Android.
Is there anything wrong with the string, making it not Android-compatible?
|
The command line work properly , special characters are allowed in the SSID (doesn't need to be escaped) but in the password it should be escaped.
| Generate a QR-code to log into Wireless (wifi) with WPA encryption |
1,461,595,270,000 |
When we execute command wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf for connecting to AP, wpa_supplicant follows following steps:
1. wpa_supplicant requests the kernel driver to scan neighboring BSSes
2. wpa_supplicant selects a BSS based on its configuration
3. wpa_supplicant requests the kernel driver to associate with the
chosen BSS
Is there any way to skip the scanning part i.e. step no.1 ?
Since scanning takes considerably few seconds, as local env have 50+ SSID.
|
The wpa_supplicant need to gather some information about an AP ( availability , ESSID, BSSID ,Freq , security , channel ...) , for every connect request it will invoke some functions to update the BSS table.
Without the BSS table update the wpa_supplicant can't handle any change on an AP, so it is not possible to skip scanning.
| Skip scanning in wpa_supplicant |
1,461,595,270,000 |
I'd like to connect to wireless network via command line in Linux.
When doing it I've stuck with this issue:
$ wpa_passphrase NETWORK_SSID NETWORK_PASSWORD
Passphrase must be 8..63 characters
The NETWORK_PASSWORD has only five characters.
Via smartphone there is no problem with connection. Could you help me to
solve this?
|
wpa_passphrase is used for generating keys for automatic WPA connections. If you want a manual one time from the command line setup use iwconfig wlan0 essid NETWORK_ID key WIRELESS_KEY
| wpa_passphrase must be 8..63 characters |
1,461,595,270,000 |
I just installed Arch Linux on my laptop. So far I have only been able to connect to wired networks. When I try to connect to my wifi network with wpa_supplicant -D nl80211,wext -i wlp3s0 -C <(wpa_passphrase "SKYNET-5GHz" < password.txt) I get this error:
Successfully initialized wpa_supplicant
Could not unlink existing ctrl_iface socket '/dev/fd/63/wlp3s0': Not a directory
Failed to initialize control interface '/dev/fd/63'.
You may have another wpa_supplicant process already running or the file was
left by an unclean termination of wpa_supplicant in which case you will need
to manually remove this file before starting wpa_supplicant again.
nl80211: deinit ifname=wlp3s0 disabled_11b_rates=0
I did some reading and found this:
Note: Because of the process substitution, you cannot run this command with sudo - you will need a root shell. Just pre-pending sudo will lead to the following error:
Successfully initialized wpa_supplicant
Failed to open config file '/dev/fd/63', error: No such file or directory
Failed to read or parse configuration '/dev/fd/63'
WPA supplicant - Connecting with wpa_passphrase | wiki.archlinux.org
That says I need to be in a root shell rather than running with the sudo prefix. The thing is, that's what I have been doing. I have tried this by logging into my computer as root and as logging in with my user and switching to root with su - root, but I always get this error.
|
According to wiki.archlinux You can use one connection manager because:
you should not run two daemons simultaneously
netctl is installed by default, i think you are using a GUI like Network-manager.
Remove netctl and Network-manager
Reinstall Network-Manager
Try to connect through wpa_supplicant
| Cannot connect to wifi with wpa_supplicant |
1,461,595,270,000 |
I'm trying to connect to a WiFi with WPA-EAP, but it always fails with error:
failure to add network: invalid message format
Full log from journalctl:
NetworkManager[668]: <info> device (wlp5s0): Activation: starting connection 'eduroam' (1ed02f15-9f55-452c-9b1c-4b2670bb2eac)
NetworkManager[668]: <info> audit: op="connection-activate" uuid="1ed02f15-9f55-452c-9b1c-4b2670bb2eac" name="eduroam" pid=3216 uid=1000 result="success"
NetworkManager[668]: <info> device (wlp5s0): state change: disconnected -> prepare (reason 'none') [30 40 0]
NetworkManager[668]: <info> manager: NetworkManager state is now CONNECTING
NetworkManager[668]: <info> device (wlp5s0): set-hw-addr: reset MAC address to 80:86:F2:1D:79:41 (preserve)
NetworkManager[668]: <info> device (wlp5s0): state change: prepare -> config (reason 'none') [40 50 0]
NetworkManager[668]: <info> device (wlp5s0): Activation: (wifi) access point 'eduroam' has security, but secrets are required.
NetworkManager[668]: <info> device (wlp5s0): state change: config -> need-auth (reason 'none') [50 60 0]
kernel: IPv6: ADDRCONF(NETDEV_UP): wlp5s0: link is not ready
NetworkManager[668]: <info> device (wlp5s0): state change: need-auth -> prepare (reason 'none') [60 40 0]
NetworkManager[668]: <info> device (wlp5s0): state change: prepare -> config (reason 'none') [40 50 0]
NetworkManager[668]: <info> device (wlp5s0): Activation: (wifi) connection 'eduroam' has security, and secrets exist. No new secrets needed.
NetworkManager[668]: <info> Config: added 'ssid' value 'eduroam'
NetworkManager[668]: <info> Config: added 'scan_ssid' value '1'
NetworkManager[668]: <info> Config: added 'key_mgmt' value 'WPA-EAP'
NetworkManager[668]: <info> Config: added 'proto' value 'RSN'
NetworkManager[668]: <info> Config: added 'pairwise' value 'CCMP'
NetworkManager[668]: <info> Config: added 'group' value 'CCMP TKIP'
NetworkManager[668]: <info> Config: added 'password' value '<hidden>'
NetworkManager[668]: <info> Config: added 'eap' value 'PEAP'
NetworkManager[668]: <info> Config: added 'fragment_size' value '1266'
NetworkManager[668]: <info> Config: added 'phase2' value 'auth=MSCHAPV2'
NetworkManager[668]: <info> Config: added 'ca_cert' value '<mypath>/ca.pem'
NetworkManager[668]: <info> Config: added 'altsubject_match' value 'DNS:<mydomain.com>'
NetworkManager[668]: <info> Config: added 'identity' value '<myusername>'
NetworkManager[668]: <info> Config: added 'anonymous_identity' value ''
NetworkManager[668]: <info> Config: added 'bgscan' value 'simple:30:-65:300'
NetworkManager[668]: <info> Config: added 'proactive_key_caching' value '1'
NetworkManager[668]: <warn> sup-iface[0x5609a63bf980,wlp5s0]: assoc[0x5609a63c8f40]: failure to add network: invalid message format
NetworkManager[668]: <info> device (wlp5s0): state change: config -> failed (reason 'supplicant-failed') [50 120 10]
NetworkManager[668]: <info> manager: NetworkManager state is now DISCONNECTED
NetworkManager[668]: <warn> device (wlp5s0): Activation: failed for connection 'eduroam'
NetworkManager[668]: <info> device (wlp5s0): state change: failed -> disconnected (reason 'none') [120 30 0]
kernel: IPv6: ADDRCONF(NETDEV_UP): wlp5s0: link is not ready
NetworkManager[668]: <info> device (wlp5s0): set-hw-addr: set MAC address to 16:09:73:46:D9:3E (scanning)
kernel: IPv6: ADDRCONF(NETDEV_UP): wlp5s0: link is not ready
What I am doing wrong?
|
The problem was solved by removing this line:
anonymous-identity=
from /etc/NetworkManager/system-connections/conname.
| Can't connect to WiFi with WPA-EAP |
1,461,595,270,000 |
I'm brand new to server configuration. I'm just a developer, so forgive me if I don't understand what you're talking about, if I haven't posted enough information, or if I don't understand your terminology.
You should know that my SSID is hidden. I have confirmed both the SSID and passkey are correct on a computer that is connected to the network.
What I've done so far:
Installed Debian (Jessie) to an i386 "server."
Installed wpa_supplicant.
Read the "README.modes" file associated with wpa_supplicant
Attempted to use the non-roaming method by changing my "interface" file in the "network" directory.
My attempt at #4 on that list was guided by this post. I did the following...
Change the "interface" file permissions.
Run the "wpa_passphrase" command.
Copy the hashed PSK to the "interface" file.
My "interface" file now contains...
auto wlan0
iface wlan0 inet dhcp
wpa-ap-scan 1
wpa-scan-ssid 1
wpa-ssid mySSID
wpa-psk myHashedPSK
I have confirmed that my device is recognized by using "iwconfig" and that it is indeed defined as "wlan0."
The Problem:
"ifup wlan0" returns the following...
run-parts: failed to stat component /etc/network/if-pre-up.d/wpasupplicant: No such file or directory
Failed to bring up wlan0.
I have navigated to "/etc/network/if-pre-up.d/" and found something there named "wpasupplicant." When I open it in the text editor using "pico" I am greeted with what I assume is a completely empty file.
What is wrong with my configuration, and how do I fix it?
|
You are missing the wpasupplicant package. You need to install it properly first.
You can do it with apt-get as below:
apt-get install wpasupplicant
Make sure it is properly installed.
And then to be on the safe side, put double quotes around the values like following and try again:
wpa-ssid "mySSID"
wpa-psk "myHashedPSK"
| Failure starting Wlan connection with wpa_supplicant? |
1,461,595,270,000 |
I'm not able to use wpa_supplicant to set the essid and other parameters on the wireless interface.
Using -Dwext throws ioctl[SIOCSIWENCODEEXT]
$ sudo wpa_supplicant -B -i wlan0 -Dwext -c universitywpa
Successfully initialized wpa_supplicant
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
and also fails to set the ESSID:
$ iwconfig wlan0
wlan0 IEEE 802.11abgn ESSID:off/any
Mode:Managed Frequency:2.412 GHz Access Point: Not-Associated
Tx-Power=15 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:off
If I use -Dnl80211, no IOCTL error is thrown:
$ sudo wpa_supplicant -B -i wlan0 -Dnl80211 -c universitywpa
Successfully initialized wpa_supplicant
But the ESSID is still off/any:
$ iwconfig wlan0
wlan0 IEEE 802.11abgn ESSID:off/any
Mode:Managed Frequency:2.412 GHz Access Point: Not-Associated
Tx-Power=15 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:off
I run the same command with -d (verbose) to see what might be going on:
$ sudo wpa_supplicant -B -i wlan0 -Dnl80211 -c universitywpa -d
wpa_supplicant v2.3
random: Trying to read entropy from /dev/random
Successfully initialized wpa_supplicant
Initializing interface 'wlan0' conf 'universitywpa' driver 'nl80211' ctrl_interface 'N/A' bridge 'N/A'
Configuration file 'universitywpa' -> '/home/my-user/repos/university_connect/universitywpa'
Reading configuration file '/home/my-user/repos/university_connect/universitywpa'
Priority group 0
id=0 ssid='UNIVERSITY-SECURE'
rfkill: initial event: idx=0 type=2 op=0 soft=0 hard=0
rfkill: initial event: idx=1 type=1 op=0 soft=0 hard=0
rfkill: initial event: idx=43 type=2 op=0 soft=0 hard=0
nl80211: Supported cipher 00-0f-ac:1
nl80211: Supported cipher 00-0f-ac:5
nl80211: Supported cipher 00-0f-ac:2
nl80211: Supported cipher 00-0f-ac:4
nl80211: Using driver-based off-channel TX
nl80211: interface wlan0 in phy phy0
nl80211: Set mode ifindex 3 iftype 2 (STATION)
nl80211: Subscribe to mgmt frames with non-AP handle 0x7ff6aa428fc0
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x7ff6aa428fc0 match=040a
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame match - hexdump(len=2): 04 0a
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x7ff6aa428fc0 match=040b
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame match - hexdump(len=2): 04 0b
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x7ff6aa428fc0 match=040c
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame match - hexdump(len=2): 04 0c
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x7ff6aa428fc0 match=040d
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame match - hexdump(len=2): 04 0d
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x7ff6aa428fc0 match=090a
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame match - hexdump(len=2): 09 0a
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x7ff6aa428fc0 match=090b
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame match - hexdump(len=2): 09 0b
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x7ff6aa428fc0 match=090c
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame match - hexdump(len=2): 09 0c
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x7ff6aa428fc0 match=090d
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame match - hexdump(len=2): 09 0d
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x7ff6aa428fc0 match=0409506f9a09
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame match - hexdump(len=6): 04 09 50 6f 9a 09
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x7ff6aa428fc0 match=7f506f9a09
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame match - hexdump(len=5): 7f 50 6f 9a 09
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x7ff6aa428fc0 match=0801
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame match - hexdump(len=2): 08 01
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x7ff6aa428fc0 match=06
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame match - hexdump(len=1): 06
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x7ff6aa428fc0 match=0a07
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame match - hexdump(len=2): 0a 07
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x7ff6aa428fc0 match=0a11
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame match - hexdump(len=2): 0a 11
nl80211: Failed to register Action frame processing - ignore for now
netlink: Operstate: ifindex=3 linkmode=1 (userspace-control), operstate=5 (IF_OPER_DORMANT)
nl80211: driver param='(null)'
Add interface wlan0 to a new radio phy0
nl80211: Regulatory information - country=00
nl80211: 2402-2472 @ 40 MHz 20 mBm
nl80211: 2457-2482 @ 40 MHz 20 mBm (no IR)
nl80211: 2474-2494 @ 20 MHz 20 mBm (no OFDM) (no IR)
nl80211: 5170-5250 @ 80 MHz 20 mBm (no IR)
nl80211: 5250-5330 @ 80 MHz 20 mBm (DFS) (no IR)
nl80211: 5490-5730 @ 160 MHz 20 mBm (DFS) (no IR)
nl80211: 5735-5835 @ 80 MHz 20 mBm (no IR)
nl80211: 57240-63720 @ 2160 MHz 0 mBm
nl80211: Added 802.11b mode based on 802.11g information
wlan0: Own MAC address: a0:88:b4:98:95:d4
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=3 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=4 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=3 (wlan0) alg=0 addr=(nil) key_idx=5 set_tx=0 seq_len=0 key_len=0
wlan0: RSN: flushing PMKID list in the driver
nl80211: Flush PMKIDs
wlan0: Setting scan request: 0.100000 sec
TDLS: TDLS operation not supported by driver
TDLS: Driver uses internal link setup
wlan0: WPS: UUID based on MAC address: 886beebd-10cf-544f-bba7-5c23f8ceb3b3
EAPOL: SUPP_PAE entering state DISCONNECTED
EAPOL: Supplicant port status: Unauthorized
nl80211: Skip set_supp_port(unauthorized) while not associated
EAPOL: KEY_RX entering state NO_KEY_RECEIVE
EAPOL: SUPP_BE entering state INITIALIZE
EAP: EAP entering state DISABLED
wlan0: Added interface wlan0
wlan0: State: DISCONNECTED -> DISCONNECTED
nl80211: Set wlan0 operstate 0->0 (DORMANT)
netlink: Operstate: ifindex=3 linkmode=-1 (no change), operstate=5 (IF_OPER_DORMANT)
Daemonize..
$
I notice these:
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Failed to register Action frame processing - ignore for now
But I'm not sure how to interpret this.
Why is the ESSID not being set?
If I run iwconfig manually, I can set the ESSID:
sudo iwconfig wlan0 essid UNIVERSITY-SECURE
$ iwconfig wlan0
wlan0 IEEE 802.11abgn ESSID:"UNIVERSITY-SECURE"
Mode:Managed Frequency:2.412 GHz Access Point: Not-Associated
Tx-Power=15 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:off
$
But obviously there's more than the ESSID needed to get the connection to work.
contents of universitywpa:
network={
ssid="UNIVERSITY-SECURE"
scan_ssid=1
key_mgmt=WPA-EAP
pairwise=CCMP TKIP
group=CCMP TKIP
eap=PEAP
identity="my-user"
password="mypass"
ca_cert="university_comodo_cert.pem"
phase1="peapver=0"
phase2="MSCHAPV2"
}
I've used these settings to connect on other machines without problems. But I've always used -Dwext, never -Dnl80211.
lshw wireless interface:
*-network
description: Wireless interface
product: Centrino Advanced-N 6205 [Taylor Peak]
vendor: Intel Corporation
physical id: 0
bus info: pci@0000:03:00.0
logical name: wlan0
version: 34
serial:
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
configuration: broadcast=yes driver=iwlwifi driverversion=3.16.0-4-amd64 firmware=18.168.6.1 latency=0 link=no multicast=yes wireless=IEEE 802.11abgn
the driver is iwlwifi.
Is this a problem between iwlwifi and -Dnl80211? How do I further diagnose this issue?
|
I ended up removing the -B (run daemon in background)
sudo wpa_supplicant -i wlan0 -c wpaconfig -D nl80211,wext
and realize that my script wasn't waiting for the connection to complete:
wlan0: CTRL-EVENT-CONNECTED - Connection to 00:11:22:33:44:55 completed [id=0 id_str=]
and was aborting early due to not seeing the essid. There seems to be no option to programmatically ask wpa_supplicant to daemonize itself only upon CTRL-EVENT-CONNECTED, so I might have to use a expect script for this.
| wpa_supplicant unable to set essid and other parameters from config file |
1,461,595,270,000 |
I just reinstalled ArchLinux on my Thinkpad. I am a bit puzzled that the network-manager-applet only supports WEP encryption for wifi networks.
I already installed wpa_supplicant and wireless_tools as suggested elsewhere on the internet.
0 ✓ user@alcor ~ $ pacaur -Qs network
local/libnm-glib 1.4.4-1
NetworkManager library
local/network-manager-applet 1.4.2-1
Applet for managing network connections
local/networkmanager 1.4.4-1
Network connection manager and user applications
local/nm-connection-editor 1.4.2-1
NetworkManager GUI connection editor and widgets
I'm running ArchLinux with kernel 4.8.13-1-ARCH and the classic Mate Desktop environment in GTK-2 version.
How to enable WPA and WPA2 for the Network Manager Applet?
|
Ok I was confusing two things: (1) creating new networks with the network-manager-applet only supports unencrypted or WEP encryption, as shown in the screenshot above. (2) Connecting to WPA secured wi-fi networks works with wireless_tools and wpa_supplicant installed.
However, it did not work in my case because I was using the network-manager-applet which was designed for GNOME on a MATE desktop environment. Here is the important snippet from the Arch Wiki:
Troubleshooting
No prompt for password of secured Wi-Fi networks
When trying to connect to a secured Wi-Fi network, no prompt for a password is shown and no connection is established. This happens when no keyring package is installed. An easy solution is to install gnome-keyring. If you want the passwords to be stored in encrypted form, follow GNOME Keyring to set up the gnome-keyring-daemon.
My mate installation was lacking a keyring. Installing gnome-keyring fixed the issue.
$ sudo pacman -S gnome-keyring
I am now able to use the WPA secured wi-fi networks again.
| How to enable WPA/WPA2 in NetworkManager? |
1,461,595,270,000 |
I notice WPA_GUI has saved my WiFi password to /etc/wpa_supplicant/wpa_supplicant.conf. The unit I'm trying to set up is a shared use system on enterprise WiFi that logs on with a user's account, so leaking the password between users is a very bad thing. There's no option in WPA_GUI to not save the password.
How can I set the system up to force each user to give their username/password to connect, and not have them stored? Note I would prefer to avoid using actual corresponding user accounts on the system.
|
We ended up using a wired network -- at the same time as I was failing to get NetworkManager/nm-applet working we got permission to plug the Pis in to the network. However I know from Xubuntu that nm-applet can connect to WPA2/PEAP and prompt for a password every time, so this should be the solution.
| Connect to WiFi without storing password (Raspbian) |
1,461,595,270,000 |
airodump-ng --ivs --channel 1 --write output --bssid VV:II:CC:TT:II:MM mon0
https://en.wikipedia.org/wiki/Initialization_vector
Question: If we use "--ivs" to make smaller outputs, will we be still able to crack WPA?
|
Yes, you will still be able to crack WPA. -i or --ivs is used to only save IVs, which is only useful for cracking anyway.
| Using "--ivs" is a good way for making a smaller output? |
1,461,595,270,000 |
I start hostapd for wpa3 only auth.
interface=wlan0
bridge=br0
driver=nl80211
ssid=mysid
hw_mode=g
channel=6
wpa=2
wpa_passphrase=iforgotit
wpa_key_mgmt=SAE
rsn_pairwise=CCMP
But when I do the scan
nmcli device wifi list it report...WEP!
nmcli device wifi list
IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY
E**************** Mysid Infra 6 65 Mbit/s 97 ▂▄▆█ WEP
Why?
How to disable wep?
edit1: i add this
auth_algs=1
but don't work, is still wep
|
Solution found: my hardware don't support wpa3 as AP
If I configure it as WPA2 the WEP disappear and WPA2 appear.
I prefer wpa3, but wpa2 is better than wep.
Another solution which works (On Slackware 15 with kernel 6.3 and module rtw_8821cu with this hardware)
wpa2 conf
interface=wlan2
bridge=br0
driver=nl80211
ssid=wpa2sid
hw_mode=g
channel=7
#macaddr_acl=1
#accept_mac_file=/etc/hostapd/hostapd.accept
wmm_enable=1
wpa=2
wpa_passphrase=yourpass!wpa2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
wpa3
interface=wlan2
bridge=br0
driver=nl80211
ssid=wpa3ssid
hw_mode=g
channel=7
#macaddr_acl=1
#accept_mac_file=/etc/hostapd/hostapd.accept
wmm_enable=1
wpa=2
wpa_passphrase=yourpass!wpa3
wpa_key_mgmt=SAE
rsn_pairwise=CCMP
| hostapd: I want wpa3 only..but enable WEP! |
1,461,595,270,000 |
Is it possible to deactivate wpa_cli notifications/messages like <3>WPS_AP_AVAILABLE? Because it spams it, and in a VT where you have to slowly type MACs@ and bssIDs, it's really hard with those bothering messages
|
Sadly, no. This function is responsible for deciding if events sent from wpa_supplicant to wpa_cli are written to the interactive terminal.
static int wpa_cli_show_event(const char *event)
{
const char *start;
start = os_strchr(event, '>');
if (start == NULL)
return 1;
start++;
/*
* Skip BSS added/removed events since they can be relatively frequent
* and are likely of not much use for an interactive user.
*/
if (str_starts(start, WPA_EVENT_BSS_ADDED) ||
str_starts(start, WPA_EVENT_BSS_REMOVED))
return 0;
return 1;
}
The only events that are not written are WPA_EVENT_BSS_ADDED and WPA_EVENT_BSS_REMOVED (which is good because they can happen hundreds of times when a scan is executed). Fastest way to stop this message from printing in your interactive terminal would be to modify the if statement to
...
if (str_starts(start, WPA_EVENT_BSS_ADDED) ||
str_starts(start, WPA_EVENT_BSS_REMOVED) ||
str_starts(start, WPS_EVENT_AP_AVAILABLE))
...
You could also add in any other messages you find annoying - the macros are defined here.
| Deactivate wpa_cli notifications |
1,461,595,270,000 |
I just wanted to try out how to connect to my WIFI WPA2 via terminal.
Therefore I created "/etc/wpa_supplicant"
network = {
ssid = "nameOfWifi"
psk = "passwordNumberThatIFoundOnTheWifiHardware"
}
Then I started following command
sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf -D nl89211
No Errors thrown. Up to the last step
Launching command to connect to my Wifi now
sudo dhclient -v wlan0
Output:
//Meta infos...
Listening on LPF/wlan0/00:1e:65:bb:4e:ee
Sending on LPF/wlan0/00:1e:65:bb:4e:ee
Sending on Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 97 interval 3 (xid:0x18018e53)
DHCPDISCOVER on wlan0 to 255.255.255.255 port 97 interval 4 (xid:0x18018e53)
DHCPDISCOVER on wlan0 to 255.255.255.255 port 97 interval 5 (xid:0x18018e53)
//repeating
What do I miss here? If there're wrong credentials - how can I figure out some error message for that case? Is there a more detailed debug/verbose?
|
You need to use wpa_passphrase when creating a configuration file for a WPA network. wpa_passphrase is included with the wpa_supplicant package.
Example:
wpa_passphrase "nameOfWifi" "password" > /etc/wpa_supplicant.conf
| dhclient connecting to wlan0 after wpa-supplicant setup polls infinitely |
1,461,595,270,000 |
If we have a CentOS 7 desktop and a big wordlist and a WPA out.ivs capture (--ivs with airodump-ng), how can we use hashcat (without installing it via the package manager) to use the wordlist to "attack" the .ivs capture file to guess the password?
|
Convert the ivs file to hccap:
aircrack-ng out.ivs -J out.hccap
and then:
hashcat --words-skip=0 --hash-type=2500 --outfile=cracked.txt --threads=4 out.hccap WORDLIST.txt
I tried the latest aircrack-ng and hashcat on a T450 with an Ubuntu 15 LiveCD. aircrack-ng did ~1700 pw/sec, hashcat did ~1600-1650 pw/sec. Both were using 4 cores, "htop" showd it.
| How to use hashcat on CentOS 7 to crack WPA with wordlist? |
1,461,595,270,000 |
When running:
airodump-ng --ivs --channel 1 --write output --bssid VV:II:CC:TT:II:MM mon0
Question: When do I know I captured the WPA 4 way handshake?
|
airodump-ng puts the phrase "WPA handshake:" in the upper right hand of the terminal window when it has captured the handshake.
See this tutorial for confirmation.
| When do I know I captured the WPA 4 way handshake? |
1,461,595,270,000 |
I'm trying to set up a connection to a WPA2-Personal network on a barebones Debian install. I've installed the firmware for my wireless adapter just fine (ipw2200) and can connect to open wireless networks perfectly. I've run through Debian's WiFi/HowToUse documentation a few times now, and each time it doesn't work. Here's my current configuration files:
/etc/network/interfaces:
auto MyOpenNetwork inet dhcp
wireless-ssid MyOpenNetworkSSID
auto MyWPANetwork inet dhcp
wpa-conf /etc/wpa_supplicant/MyWPANetwork.conf
/etc/wpa_supplicant/MyWPANetwork.conf:
network={
ssid="MyWPASSID"
psk=LotsOfHexGeneratedBywpa_passphrase
}
Also, running ifup eth1=MyNetwork throws:
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
And wpa_supplicant -D wext -i eth1 -c /etc/wpa_supplicant/MyWPANetwork.conf throws:
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
eth1: Trying to associate with XX:XX:XX:XX:XX:XX (SSID='MyWPASSID' freq=XXXX MHz)
eth1: Association request to the driver failed
Any help would be much appreciated, thanks!
|
Answering my own question to close; it seems the issue is on the network's end and not mine, I've since been able to connect to other WPA2 networks just fine.
| Cannot connect to WPA2, but connecting to WEP is fine |
1,461,595,270,000 |
[root@notebook /opt/aircrack-ng] dmesg -C
[root@notebook /opt/aircrack-ng] aireplay-ng --test wlan0
ioctl(SIOCSIWMODE) failed: Device or resource busy
ARP linktype is set to 1 (Ethernet) - expected ARPHRD_IEEE80211,
ARPHRD_IEEE80211_FULL or ARPHRD_IEEE80211_PRISM instead. Make
sure RFMON is enabled: run 'airmon-ng start wlan0 <#>'
Sysfs injection support was not found either.
[root@notebook /opt/aircrack-ng] dmesg
[37950.649811] wlan0: deauthenticating from 92:f6:52:f5:aa:d9 by local choice (reason=3)
[37950.664362] cfg80211: All devices are disconnected, going to restore regulatory settings
[37950.664371] cfg80211: Restoring regulatory settings
[37950.664697] cfg80211: Calling CRDA to update world regulatory domain
[37950.672526] cfg80211: Ignoring regulatory request Set by core since the driver uses its own custom regulatory domain
[37950.672531] cfg80211: World regulatory domain updated:
[37950.672533] cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
[37950.672536] cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[37950.672539] cfg80211: (2457000 KHz - 2482000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
[37950.672541] cfg80211: (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
[37950.672543] cfg80211: (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[37950.672546] cfg80211: (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[root@notebook /opt/aircrack-ng]
I alread did
airmon-ng start wlan0
My question: since the test failed, I never get a "WPA handshake" when using "airodump-ng". What am I missing? I'm using Ubuntu 12.04. How can I succeed at the test and make a WPA handshake? Using other driver? I tried two wireless cards: an USB stick: "050d:705e" and a built-in "Intel Corporation Centrino Advanced-N 6200 (rev 35)"
UPDATE: there isn't any dmesg messages when using: airodump-ng
|
The solution is based on two parts:
1 - you have to have a wireless card that supports packet injection. Mine wasn't good, so I bough a TL-WN722N*.
2- The channel needs to be set when starting in monitor mode (even with the TL-WN722N):
airmon-ng start wlan0 1
*-> additional info: The TL-WN722N that works uses ath9k driver, and lsusb output:
Bus 001 Device 007: ID 0cf3:9271 Atheros Communications, Inc. AR9271 802.11n
| Why doesn't WPA handshake occur? |
1,537,709,960,000 |
I use xinetd and it works for my purposes. However I recently discovered that systemd has something built in called "socket activation".
These two seem very similar, but systemd is "official" and seems like the better choice.
However before using it, are they really the same? Are there differences I should be aware of?
For example, I want to start some dockerised services only when they are first requested - my first thought would be to use xinetd. But is socket activation better / faster / stabler / whatever?
|
I don’t think systemd socket activation is significantly better than xinetd activation, when considered in isolation; the latter is stable too and has been around for longer. Socket activation is really interesting for service decoupling: it allows services to be started in parallel, even if they need to communicate, and it allows services to be restarted independently.
If you have a service which supports xinetd-style activation, it can be used with socket activation: a .socket description with Accept=true will behave in the same way as xinetd. You’ll also need a .service file to describe the service. The full benefits of systemd socket activation require support in the dæmon providing the service. See the blog post on the topic.
My advice tends to be “if it isn’t broken, don’t fix it”, but if you want to convert an xinetd-based service to systemd it’s certainly feasible.
| systemd "socket activation" vs xinetd |
1,537,709,960,000 |
I have a CentOS 7 system which uses systemd, and I want to start a tftp server. I'm confused about the right way to do this. I've seen some posts that say install xinetd and launch it from there (like pre-systemd), and other posts that say enable tftp.socket
Is xinetd just a bridge to systemctl socket which will eventually go away?
If so, where would I place my tftp configuration settings (since the xinetd tftp file would not be used)
|
No, is not a bridge to systemctl, it's just the traditional daemon.
So you can choose whether you start tftp with xinetd or with systemd socket.
Nice explanation on systemd blog:
http://0pointer.de/blog/projects/inetd.html.
| systemd vs xinetd |
1,537,709,960,000 |
I need to keep track of all SSH connections on my server. In my /etc/hosts.allow I have something like this:
sshd: ALL : spawn ( echo "`date` from %u %a " >> /var/log/ssh/%d.log ) &
where %a logs the client IP, and %u is supposed to log the username. But instead %u just logs unknown. Is there a way to fix this? I need to log both the IP and the username for each connection.
|
The %u client user name is only known if the client side machine is running identd and provides the username on request.
tcp wrappers i.e. tcpd does the identd lookup and returns "unknown" if it doesn't get an answer from the client machine.
Running identd used to be common practice back in the 90s, but is extremely uncommon these days - and many clients (Windows machines, for example) don't even have an identd or similar program.
In short, you get "unknown" because the client machine isn't providing that information.
Your sshd should be logging all connection attempts anyway - check /var/log/auth.log or /var/log/syslog or /var/log/messages (depending on your distribution and on how your syslogd is configured).
| hosts.allow: %u not working (log username) |
1,537,709,960,000 |
Whenever I think I'm getting comfortable with Linux, I get stumped by a simple problem that exposes my inexperience: how do I launch the daytime service? My trail of attempts is as follows:
>sudo systemctl start daytime
Failed to issue method call: Unit daytime.service failed to load: No such file or directory.
>which daytime
/usr/bin/which: no daytime in (/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/user/utils/:/home/user/.local/bin:/home/user/bin:/home/user/utils/:/home/user/utils/:/home/user/utils/:/home/user/.local/bin:/home/user/bin:/home/user/utils/)
>locate daytime
/etc/xinetd.d/daytime-dgram
/etc/xinetd.d/daytime-stream
>sudo systemctl start daytime-stream
Failed to issue method call: Unit daytime-stream.service failed to load: No such file or directory.
>systemctl status xinetd
xinetd.service - Xinetd A Powerful Replacement For Inetd
Loaded: loaded (/usr/lib/systemd/system/xinetd.service; enabled)
Active: active (running) since Mon 2017-06-12 18:10:28 PDT; 16h ago
Process: 5005 ExecStart=/usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid $EXTRAOPTIONS (code=exited, status=0/SUCCESS)
Main PID: 5006 (xinetd)
CGroup: /system.slice/xinetd.service
/usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid
>uname -a
Linux linuxbox 3.11.10-301.fc20.x86_64 #1 SMP Thu Dec 5 14:01:17 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
I have a very shaky understanding that there is some relationship between xinetd and daytime, but, e.g., I don't understand if the fact that the xinetd service is running means that daytime is/should also be running, or if I need to start it independently? If I am supposed to start it independently, then how can I? I'm out of ideas after my above-noted attempts all failed.
|
The xinetd daemon essentially listens for requests and then launches given service for it. Wikipedia entry for xinetd.
From the OP's question, one can see /etc/xindet.d/daytime-stream, which means that xinetd is installed, along with the daytime service. However, as it is generally recommended for daytime to not be enabled see, e.g., acunetix and security scanning, it must be specifically enabled. To enable it, edit the file /etc/xinetd.d/daytime-stream and change the disabled from 'yes' to 'no` (backwards logic is backwards).
After restarting the xinetd via sudo systemctl xinetd restart (or equivalent), the xinetd daemon will start the service when a request is made on the port. The mapping between the port and the service is defined in /etc/services (but may be specified in the relevant xinetd file).
| How do I launch the daytime service? |
1,537,709,960,000 |
I've been learning about socket programming recently, and am just beginning learning about tcp/ip sockets. My study material gives an example of connecting to the localhost daytime service by running telnet 127.0.0.1 13 with the expected result that a telnet session should be opened. I have an entry for "daytime 13/tcp" in my /etc/services file, and I have the xinetd service running, but when I try the telnet command, I immediately get "Connection refused".
Q: why doesn't telnetting to the daytime service work?
Q: are there other localhost services that would accept a telnet connection? I tried to telnet to a random selection of services that had tcp entries in /etc/services, but all of them gave the same "Connection refused" error.
My short-term goal is just to replicate my study material's successful telnet connection to a localhost tcp service - if not inetd, then anything else; I just want to learn by practice.
>telnet 127.0.0.1 13
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
>telnet 127.0.0.1 49000
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
>telnet 127.0.0.1 9009
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
>uname -a
Linux linuxbox 3.11.10-301.fc20.x86_64 #1 SMP Thu Dec 5 14:01:17 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
|
The /etc/services does not indicate what services are actually running. See purpose of /etc/services. You will need to find a service that is running (or start one). You can see what is listening by looking at netstat -nlt. The particular services will vary, but you will see something like:
$ netstat -nlt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp6 0 0 :::3306 :::* LISTEN
tcp6 0 0 :::111 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 ::1:25 :::* LISTEN
So:
daytime service is probably not running. If it does not appear in the list (and you can see from the listing above I do not have it running), then nothing is listening on the port. It may be possible to start the service if it is installed.
There are lots of other potential services depending upon what is installed and active. In the listing above, port 25 is listening, which is the mail service. So I could connect via telnet to port 25. As telnet is not installed by default, I use nc to connect, but the principle is the same:
$ nc 127.0.0.1 25
220 centos7.feedthecoder.com ESMTP Postfix
HELO me.theworld.com
...
Edit: as mentioned in a comment, it could of course be a firewall issue. Generally installations do not block 127.0.0.1, but it is always a possibility.
Also, depending upon your distribution, daytime may not be installed, which would be a further impediment. If it is installed, you should be able to start it via the normal service start (e.g., service start daytime, or the distro equivalent).
Edit: it turns out that daytime is provided solely by xinetd as an internal service. So while the information above about listing services is correct, to have daytime, ensure that xinetd is installed, and that the file /etc/xinetd/daytime-stream has disabled set to no.
| What services accept tcp connection? |
1,537,709,960,000 |
I want to launch lighttpd when someone tries to connect to port 80.
I started with a simple test script to see if anything was working:
/etc/xinetd.d/www
service www
{
disable = no
socket_type = stream
protocol = tcp
port = 80
log_on_success += USERID
log_on_failure += USERID
server = /usr/server_test.sh
user = root
instances = UNLIMITED
wait = no
log_type = SYSLOG daemon debug
}
where /usr/server_test.sh:
#!/bin/sh
echo "www connection"
lighttpd -D -f /usr/lighttpd.conf &
webconfig -c /usr/cppcms.js &
service xinetd restart
When I try:
nc localhost 80
I get:
www connection 2013-11-25 16:37:13: (network.c.345) can't bind to port: 80 Address already in use
How do I get xinetd and lighttpd to work together, not fight over same port?
|
Do not do it this way, run lighttpd strictly as a daemon. The daemon xinetd is mean to start services that are not actually running all the time. When xinetd sees traffic it "spins up" a particular service to meet the need, but otherwise the processes are not running.
By the way, you cannot share a TCP port between 2 daemons/services. Only one service can bind to a particular TCP port, essentially owning it for the duration of the time that it's running.
Doing it anyway
If you're absolutely sure you want to run it like this then take a look at this tutorial that shows exactly this scenario on a Raspberry Pi. The tutorial is titled: Starting mysqld and httpd on demand with xinetd.
This script was created, /etc/xinetd.init.d/lighttpd:
#!/bin/bash
# inspired on this article
# https://www.linuxnet.ch/automatic-tunnels-with-xinetd-and-netcat/
# script is called from xinetd
# script starts and stops service using /etc/init.d scripts
SERVICE=/etc/init.d/lighttpd # script used to start/stop service
PORT=81 # port where end service should listen
PID_FILE=/var/run/lighttpd.pid # pid file generated by init script
REAPER_PID_FILE="/var/run/lighttpd_reaper.pid" # pid file generated by this script
REAPER_SLEEP=180 # The reaper sleeps in seconds and checks for idle conns
LOG=/var/log/syslog # where to log messages
# this function checks if we already have reaper
check_reaper(){
if [ -s $REAPER_PID_FILE ]
then
reaper_pid=`cat $REAPER_PID_FILE 2>/dev/null`
ps -p $reaper_pid &> /dev/null
if [ $? -ne 0 ]
then
start_reaper & # If we don't have a reaper we start one
echo $! > $REAPER_PID_FILE
fi
else
start_reaper &
echo $! > $REAPER_PID_FILE
fi
}
# this function starts a reaper, which is a background process that will kill the end service if its inactive
start_reaper(){
while [ -f $PID_FILE ]
do
sleep $REAPER_SLEEP # We wait
touched=`stat --printf %W $REAPER_PID_FILE 2>/dev/null` # We check when the reaper PID was last touched
now=`date +%s 2>/dev/null`
let idle=$now-$touched
if [ $idle -gt $REAPER_SLEEP ] # If reaper pid has not been touched in more than a sleep cycle we stop the service
then
echo `date`" REAPER STOPPING SERVICE AFTER BEING $idle" >> $LOG
$SERVICE stop >> $LOG # This is the stop service instruction
rm $REAPER_PID_FILE
exit 0
fi
done
}
# This is where we start our service
start_service(){
sleep 1 # Added a delay to trouble shoot as browsers kickstart several connections, we need to allow the PID file to be created this can be improved.
if [ -s $PID_FILE ] # We check if the PID file for the end service exist to avoid calling the start script when the service has already been started
then
return
else
echo `date`" STARTING $SERVICE" >> $LOG
$SERVICE start &>> $LOG #this is the start service instruction
return
fi
}
# We probe and wait for the service to come on line
wait_for_service(){
nc -w30 -z 127.0.0.1 $PORT &>/dev/null # probe end port with a timeout of 30 seconds
if [[ $? -ne 0 ]]
then
echo `date`" XINET SERVICE START ON $PORT TIMED OUT" >> $LOG
fi
}
# This is were all the magic happens netcat passes traffic back and forth
transmit(){
nc -w30 127.0.0.1 $PORT 2>/dev/null # netcat is awesome, timeout flag of 30 seconds can be adjusted
}
# this is the main program that is called every time
main()
{
nc -z 127.0.0.1 $PORT &>/dev/null # We probe the end service
if [[ $? -ne 0 ]] # If its not responding
then
start_service # We start service
wait_for_service # We wait for service to became online
fi
check_reaper # We always check we have a reaper
touch $REAPER_PID_FILE # We log activity by touching the reaper PID file
transmit # We transmit data
exit 0
}
main
And the following xinetd service was created:
service http
{
disable = no
socket_type = stream
protocol = tcp
port = 80
server = /etc/xinetd.init.d/lighttpd
user = root
wait = no
}
| xinetd cannot launch lighttpd |
1,537,709,960,000 |
I need to run approx, a package proxy for Debian / Ubuntu packages, on an OpenSuSE box.
Until now, I converted the installation package from .deb to .rpm using alien. Installing the resulting .rpm gave me the approx binary in /usr/sbin/approx.
Under Debian, approx is started using inetd. OpenSuSE seems to prefer xinetd. So, in YaST2's xinetd setup, I created a new entry using
service name: "approx" (I also tried "9999", since I assume this is where the mapping from service names to port numbers takes place -- this name should match the port description in /etc/services, right?)
type: stream
protocol: tcp
nowait option
user: root and
service: /usr/sbin/approx.
However, no matter what status I assign the entry, the xinetd configuration jumps to "deactivated" as soon as I click "OK", and I can't get any reaction from the system when contacting it on port 9999.
So, at first, is my use of the xinetd configuration correct or do I understand something wrong there?
Second, is the automatic deactivation of the xinetd config panel in YaST2 a software or user error?
|
Thanks to Nikhil's input, I got this solved.
YaST only uses service names, not port numbers, when setting up xinetd. Unfortunately, for some historic reasons, approx defaults to port 9999. This is registered to another service, named "distinct".
So, the ad-hoc solution was to rename port 9999's service to "approx" in /etc/services and enter a new service in the xinetd config with the name "approx" (this does, as I suspected, get mapped to port 9999), user approx and group approx. This is the YaST-generated service file:
$ cat /etc/xinetd.d/approx
service approx
{
socket_type = stream
protocol = tcp
wait = no
user = approx
group = approx
server = /usr/sbin/approx
}
Of course, the proper solution will be to migrate the server and all client machines to a different port (one that is not yet assigned by IANA).
| Configuring OpenSuSE's xinetd |
1,537,709,960,000 |
When I need to use SNMP monitoring for java applications, there is the need to that application (usually ran as daemon user) to listen on snmp port.
If there is no other alternative, of course I can use another port, say 11161.
But I can use XInetd to redirect port 161 to 11161.
My question is: is this the best method? Is iptables port redirection better?
|
First of all - the Oracle-description sucks. The proper way to use SNMP for an application (java is a application with regards to the operating system) is to register it as sub-agent to the OS-snmp-service (in case of linux: snmpd).
There has to be a way to accomplish that. Afterwards you can use the SNMPD-security settings (see the man-pages of snmpd) to restrict access to that part of the MIB.
| Is xinetd still the best method to let non root daemons listen on privileged ports? |
1,537,709,960,000 |
I have a xinetd service from Centos6 and I want to port to Centos7 ie create a systemd service
# cat /etc/xinetd.d/br_rsh
# default: on
# description: The rshd server is the server for the rcmd(3) routine and, \
# consequently, for the rsh(1) program. The server provides \
# remote execution facilities with authentication based on \
# privileged port numbers from trusted hosts.
service brshell
{
port = 591
socket_type = stream
wait = no
user = root
log_on_success += USERID
log_on_failure += USERID
server = /usr/sbin/in.br_rshd
disable = no
}
If i understood correctly, i need to break down the above file to two parts: one for brshell.socket and another for brshell.service. Then, I need to execute systemctl enable brshell.socket (what about brshell.service?)
What would these files look like and Where would these files go under?
Thank you
|
I'm assuming you already know about all the risks involved in running rshd, so I'll skip the "dire warnings" section of my talk. :-)
If your distribution includes the program that you're running, there's a strong chance that it already has the correct systemd files to migrate to (/usr/lib/systemd/system is where the distribution-supplied units files are located in CentOS IIRC. This is distro-specific; for example, I use Gentoo so they're located in /lib/systemd/system for me.)
If you need to make the unit files, it's pretty easy to migrate an xinetd service. You are correct in that you need both a socket and service file. By default, they both have the same base name; however, that's not a requirement, just a simplification. For your particular case, put the following into /etc/systemd/system (this is where you should put unit files that you create yourself):
brshell.socket
[Unit]
Description=rsh Server Socket
[Socket]
ListenStream=591
Accept=yes
[Install]
WantedBy=sockets.target
brshell.service
[Unit]
Description=rsh Server Daemon
After=network.target
[Service]
ExecStart=/usr/sbin/in.br_rshd
[Install]
WantedBy=multi-user.target
That's basically it! All you need to do next is run systemd enable brshell.socket (to have it start automatically at boot) and systemd start brshell.socket.
| Centos7: Starting xinetd service with systemd |
1,537,709,960,000 |
I'm studying for the first LPIC exam. In a quiz, I've found this question:
How can you tell whether your system is using inetd or xinetd as a super server?
And the right answer should be:
Type ps ax | grep inetd, and examine the output for signs of inetd (or xinetd).
In my desktop (Fedora 21), this is the output of both cases:
15844 pts/0 S+ 0:00 grep --color=auto inetd
15848 pts/0 S+ 0:00 grep --color=auto xinetd
How should I tell which one is running, if one is running at all?
|
It's almost certainly xinetd since regular inetd is older than dirt but you can check the RPM database:
[root@xxx01 ~]# rpm -qa xinetd
xinetd-2.3.14-39.el6_4.x86_64
[root@xxx01 ~]# rpm -qa inetd
[root@xxx01 ~]#
For your commands you can probably just start the xinetd service to get the commands to work (since one isn't running it looks like).
Also, probably a better command to run than ps ax | grep <some binary> is to just use -C for example:
[root@xxx01 ~]# ps -C xinetd
PID TTY TIME CMD
1823 ? 00:00:00 xinetd
[root@xxx01 ~]#
Which eliminates extra output like you saw if you just grep the output of ps.
| Inetd and Xinetd: which is running? |
1,537,709,960,000 |
I'm using GNU's Inetutils FTP and have gotten it all set up except it does not automatically start when I turn on my system. In order to get it to work I have to start the standalone using "ftpd -D". I've figured out that I have xinetd running and I believe I need to use that to automatically start the daemon.
In the /etc/xinetd.d/ directory I've added a file named 'ftp'. Inside its contents are:
service ftpd
{
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/bin/ftpd
instances = 20
}
*Doing a whereis shows that ftpd resides in /usr/bin/ftpd*
After adding it I reloaded the configuration and restarted the server.
/etc/init.d/xinetd reload
/etc/init.d/xinetd restart
My xinetd.conf file is as followed:
# Simple configuration file for xinetd
#
# Some defaults, and include /etc/xinetd.d/
defaults
{
instances = 60
log_type = SYSLOG authpriv
log_on_success = HOST PID
log_on_failure = HOST
cps = 25 30
}
includedir /etc/xinetd.d
There was also an inetd.config file in my system so I added the following for good measure though it doesn't seem inetd is running.
ftp stream tcp nowait root /usr/bin/ftpd in.ftpd -l -a
When I try to connected to my ftp server I get the error "ECONNREFUSED - Connection refused by server". Does anyone have any idea why this isn't getting started automatically by xinetd?
I got my information from this website:
http://www.cyberciti.biz/faq/linux-how-do-i-configure-xinetd-service/
|
I figured it out. Incase anyone else has this problem in the future, I forgot to specify a port to use for the service, changed the service name to ftp and set disable to no. Here is my final service file:
service ftp
{
port = 21
disable = no
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/bin/ftpd
instances = 20
}
To get the logging working I used the following command:
/usr/sbin/xinetd -filelog /var/log/xinetd -f /etc/xinetd.conf
| Starting FTP with xinetd |
1,537,709,960,000 |
Webmin is serving static help pages.
Webmin 1.47 was using the characters set was iso-8859-1 as character encoding. This information is transmitted by the HTTP header
content type:"Text/html; Charset=iso-8859-1"
After migration to a newer configuration using Webmin 1.81, the content type header is now utf-8 instead of the old iso-8859-1. This difference result into a bad displaying of special characters.
content type:"Text/html; Charset=utf-8"
We are using the Xinet deamon.
I would like not to convert my oldest help pages but would rather indicates that older pages are encoded in iso-8859-1 in their code.
Have I to convert all my help page from iso-8859-1 to utf-8? May I indicate that the encoding is iso-8859-1 at the level of Webmin? Where is decided the encoding for the Webmin pages?
|
Since it's HTML, you should be able to use meta http-equiv or meta charset to override, by putting on of these in the document's header:
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<!-- or -->
<meta charset="iso-8859-1">
You could also check if it's actually served by Apache (or similar); most web servers will have a way to set the charset on a per-path basis.
but I fully expect iconv -f latin1 -t utf8 (convert to utf8) to be a much easier solution (of course, if any of your pages already have a meta header giving the character set, you'll have to change them—iconv doesn't do that for you).
| Webmin help page encoding : iso-8859-1 vs utf-8 |
1,537,709,960,000 |
I have have installed xinetd, and I wrote a script:
#!/bin/bash
echo "Some text"
touch /home/somefile
I made a service configuration under /etc/xinetd.d/ and basically it works
when I connect to localhost under the configured port, because: The file somefile gets generated by the touch command on connection to the service. I connect with telnet:
telnet localhost someport
What I don't understand is that telnet does not output the string
"Some text". What can I do to make this work?
Heres the xinetd service configuration file in /etc/xinetd.d/:
# This is the configuration for the tcp/stream echo service.
service my_service_name #not in /etc/services
{
# This is for quick on or off of the service
disable = no
# The next attributes are mandatory for all services
id = my_custom_id
type = UNLISTED
wait = yes
socket_type = stream
protocol = tcp
# External services must fill out the following
user = root
# group =
server = /usr/bin/program_name_here
# server_args =
# External services not listed in /etc/services must fill out the next one
port = 60001
}
|
Changing wait to no will likely solve your problem. From the man page:
If its value is yes, the service is single-threaded; this means that xinetd will start the server and then it will stop handling requests for the service until the server dies and that the server software will accept the connection.
The key bit there is that when wait is set to yes, the server software is expected to accept the connection, which your script does not do.
| Telnet no echo output from xinetd script |
1,537,709,960,000 |
I am trying to troubleshoot tftp on my Fedora 22 to see if it is working or not. All I want to do is transfer a file between two systems. The commands I am finding online are not working. All I need is the command and the directory where the files will go on both ends. I get a connection established to the tftp but when I do a get it times out.
|
You tftp server setting can be viewed in /etc/xinetd.d/tftp.
server_args = -s /tftproot # tftproot is where your tftp base directory.
Say you tftp server is hostx
From hosty, try this command
tftp hostx
> tftp get file # file is any file under this /tftproot directory.
> tftp quit
ls -l file
| Using TFTP on Fedora 22 |
1,537,709,960,000 |
Environment: CentOS 6.6
When running this simple test (from myclient):
while true; do rsh myserver "echo OK"; done
After ~500 iterations, the server runs out of ports.
netstat -anp on the server shows:
tcp 0 0 myserver:1008 myclient:922 TIME_WAIT -
tcp 0 0 myserver:975 myclient:922 TIME_WAIT -
tcp 0 0 myserver:998 myclient:922 TIME_WAIT -
tcp 0 0 myserver:991 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1007 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1000 myclient:922 TIME_WAIT -
tcp 0 0 myserver:990 myclient:922 TIME_WAIT -
tcp 0 0 myserver:979 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1003 myclient:922 TIME_WAIT -
tcp 0 0 myserver:988 myclient:922 TIME_WAIT -
tcp 0 0 myserver:984 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1002 myclient:922 TIME_WAIT -
tcp 0 0 myserver:997 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1019 myclient:922 TIME_WAIT -
tcp 0 0 myserver:995 myclient:922 TIME_WAIT -
tcp 0 0 myserver:993 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1004 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1017 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1013 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1011 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1009 myclient:922 TIME_WAIT -
tcp 0 0 myserver:994 myclient:922 TIME_WAIT -
tcp 0 0 myserver:987 myclient:922 TIME_WAIT -
tcp 0 0 myserver:986 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1012 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1010 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1014 myclient:922 TIME_WAIT -
tcp 0 0 myserver:996 myclient:922 TIME_WAIT -
922 is the RSH stderr port (from monitoring with wireshark).
After approximatively one minute, the sockets are closed on the server and new connections can be made.
So it seems the client or the server fails to properly close these sockets, and they just timeout.
Is this a bug in rsh ?
Any idea to work around this ? I can see BSD's rsh has a --no-stderr option, but Linux does not seem to.
|
Hit this before in my life... the TIME_WAIT is an artifact of TCP/IP so you are stuck with it. It can be tweaked via /proc (see serverfault 23385) but a better way would be a solution that opened a persistent socket that works as long as needed.
generate_lots_of_lines | ssh myhost 'while read line; do echo ":$line"; done;'
This way you can have one connection do many things based on what the client sends the server.
| RSH closing stderr socket with a delay? |
1,537,709,960,000 |
I'm trying to create a script that replicates a JSON status response from a Minecraft server (https://wiki.vg/Server_List_Ping). I've currently set up xinetd to execute a shell script that echos a preset back, but I'm having trouble crafting the TCP packet. For some reason it returns whatever comes after echo, ignoring any flags. Here's a stripped down case that replicates the issue:
/usr/bin/mc
#!/bin/sh
# hello!
echo -en "\x68\x65\x6c\x6c\x6f\x21"
/etc/xinetd.d/minecraft
service minecraft
{
type = UNLISTED
instances = 20
socket_type = stream
protocol = tcp
wait = no
user = root
group = root
server = /usr/bin/mc
port = 25565
disable = no
}
TCP reply data as seen from the client that initiated the request:
00000000: 2d65 6e20 5c78 3638 5c78 3635 5c78 3663 -en \x68\x65\x6c
00000010: 5c78 3663 5c78 3666 5c78 3231 0a \x6c\x6f\x21.
Do I need to read the client request first, or is echo aliased to something else if called from xinetd?
|
echo is an internal shell command. If you change the first line to:
#!/bin/bash
The program will work because echo from bash understands -en.
Otherwise, you have to see which shell is actually /bin/sh in your system and use the proper syntax for its echo command.
| xinetd + shell script echoing flags in TCP packet |
1,537,709,960,000 |
We are running several centos 6.4 lamp stacks, and our backup solution (unitrends) has a client that requires xinetd.
Can these two coexist on the same server? If so, is there any secret handshake I need to perform to keep xinetd from assuming the work of Apache?
Or am I worrying about nothing?
|
Xinetd and standalone servers can coexist without problems. Just check /etc/xinetd.d/ for the servers that are under xinetd and set to "enabled=no" the servers you want to keep standalone.
| Running xinetd and httpd on centos 6 |
1,364,611,182,000 |
I'm using this for creating backups securely (? - is it really secure? with a good password?):
# ENCRYPT
ORIGDIR="DIRECTORYNAMEHERE"; tar cvf - "${ORIGDIR}/" 2>/dev/null | gzip -9 - 2>/dev/null | openssl aes-256-cbc -salt -out "${ORIGDIR}.tar.gz.aes"
# DECRYPT
openssl aes-256-cbc -d -salt -in "ENCDIRECTORYNAMEHERE" | tar -xz -f -
Q: But how can I do this using 7z with max compression rate?
Creating temporary files besides the only OUTPUT file is not good, because if I need to compress ~100 GByte sized files/directories on a 180 GByte FS I wouldn't have enough free space (if ex.: the compressed file would take ~60 GByte).
|
Is there a reason you want to use 7z specifically, or do you just want better compression than gzip?
The xz utility uses the same compression algorithm as 7z (LZMA), and allows piped compression the same as gzip.
tar cvf ... | xz -9 | openssl ...
| How to use 7z to compress via pipe? |
1,364,611,182,000 |
At best I would like to have a call like this:
$searchtool /path/to/search/ -contained-file-name "*vacation*jpg"
... so that this tool
does a recursive scan of the given path
takes all files with supported archive formats which should at least be the "most common" like zip, rar, 7z, tar.bz, tar.gz ...
and scan the file list of the archive for the name pattern in question (here *vacation*jpg)
I'm aware of how to use the find tool, tar, unzip and alike. I could combine these with a shell script but I'm looking for a simple solution that might be a shell one-liner or a dedicated tool (hints to GUI tools are welcome but my solution must be command line based).
|
(Adapted from How do I recursively grep through compressed archives?)
Install AVFS, a filesystem that provides transparent access inside archives. First run this command once to set up a view of your machine's filesystem in which you can access archives as if they were directories:
mountavfs
After this, if /path/to/archive.zip is a recognized archive, then ~/.avfs/path/to/archive.zip# is a directory that appears to contain the contents of the archive.
find ~/.avfs"$PWD" \( -name '*.7z' -o -name '*.zip' -o -name '*.tar.gz' -o -name '*.tgz' \) \
-exec sh -c '
find "$0#" -name "*vacation*.jpg"
' {} 'Test::Version' \;
Explanations:
Mount the AVFS filesystem.
Look for archive files in ~/.avfs$PWD, which is the AVFS view of the current directory.
For each archive, execute the specified shell snippet (with $0 = archive name and $1 = pattern to search).
$0# is the directory view of the archive $0.
{\} rather than {} is needed in case the outer find substitutes {} inside -exec ; arguments (some do it, some don't).
Or in zsh ≥4.3:
mountavfs
ls -l ~/.avfs$PWD/**/*.(7z|tgz|tar.gz|zip)(e\''
reply=($REPLY\#/**/*vacation*.jpg(.N))
'\')
Explanations:
~/.avfs$PWD/**/*.(7z|tgz|tar.gz|zip) matches archives in the AVFS view of the current directory and its subdirectories.
PATTERN(e\''CODE'\') applies CODE to each match of PATTERN. The name of the matched file is in $REPLY. Setting the reply array turns the match into a list of names.
$REPLY\# is the directory view of the archive.
$REPLY\#/**/*vacation*.jpg matches *vacation*.jpg files in the archive.
The N glob qualifier makes the pattern expand to an empty list if there is no match.
| Find recursively all archive files of diverse archive formats and search them for file name patterns |
1,364,611,182,000 |
I run Linux Live CD and I need to extract a specific file from a wim-archive that is located on a disk drive. I know a full path to the file in the archive:
xubuntu@xubuntu:~$ 7z l winRE.wim | grep -i bootrec.exe
2009-08-28 15:02:29 ....A 299008 134388 Windows/System32/BootRec.exe
I am short on disk space and do not have a possibility to unpack the whole archive.
How could I extract that specific file from the archive?
I tried the -i option, but that did not work:
xubuntu@xubuntu:~$ 7z x -i Windows/System32/BootRec.exe winRE.wim
Error:
Incorrect command line
|
The man 7z page says:
-i[r[-|0]]{@listfile|!wildcard}
Include filenames
You need to explicitly specify ! before the file name and protect the switch from bash expansion with single quotes: 7z x '-i!Windows/System32/BootRec.exe' winRE.wim
xubuntu@xubuntu:~$ 7z x '-i!Windows/System32/BootRec.exe' winRE.wim
7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,4 CPUs)
Processing archive: winRE.wim
Extracting Windows/System32/BootRec.exe
Everything is Ok
Size: 299008
Compressed: 227817568
(You can avoid keeping the full path by using the e function letter: 7z e '-i!Windows/System32/BootRec.exe' winRE.wim.)
BTW, if you do not protect the -i option with single quotes or protect it with double quotes, you get an error:
xubuntu@xubuntu:~$ 7z x "-i!Windows/System32/BootRec.exe" winRE.wim
bash: !Windows/System32/BootRec.exe: event not found
| Extracting a specific file from an archive using 7-Zip |
1,364,611,182,000 |
Doing 7z x on an archive gives me
'20 ª.1 ¯® '$'\302\212''¨à®¢®£à ¤áª ï ã«.rtf' IMG_6527.JPG
''$'\302\212''¨à®¢®£à ¤áª ï, ¨áâ.doc' IMG_6532.JPG
''$'\302\204''®¯ ᮣ« 襨¥(3).doc' IMG_6542.JPG
''$'\302\204\302\212\302\217''.doc' IMG_6543.JPG IMG_6526.JPG
Clearly some files were encoded differently and 7z by default does not convert to UTF-8. How to tell 7z to do the conversion?
The only options I found for charset:
-scc{UTF-8|WIN|DOS}: set charset for for console input/output
-scs{UTF-8|UTF-16LE|UTF-16BE|WIN|DOS|{id}}: set charset for list files
WIN, DOS, UTF-8 do not work. When trying to guess charset via
7z -scsCP1251 l 26-08-2016_10-18-14.zip
7z gives warning:
Unsupported charset: cp1251
unzip does this right (cyrillic symbols got converted):
'20 к.1 по Кировоградская ул.rtf' IMG_6532.JPG 'Доп соглашение(3).doc'
26-08-2016_10-18-14.zip IMG_6542.JPG 'Кировоградская, ист.doc'
IMG_6526.JPG IMG_6543.JPG
IMG_6527.JPG ДКП.doc
Supplementary information
p7zip Version:
15.14.1 (locale=ru_RU.UTF-8,Utf16=on,HugeFiles=on,64 bits,4 CPUs AMD Phenom(tm) II X4 960T Processor (100FA0),ASM)
hexdump of start of archive (od -tx1z -Ax):
000000 50 4b 03 04 14 00 00 00 00 00 81 54 1a 49 7e 35 >PK.........T.I~5<
000010 fa 34 00 ec 00 00 00 ec 00 00 07 00 17 00 84 8a >.4..............<
000020 8f 2e 64 6f 63 75 70 13 00 01 19 fd 45 54 d0 94 >..docup.....ET..<
000030 d0 9a d0 9f 2e 64 6f 63 00 00 00 00 d0 cf 11 e0 >.....doc........<
000040 a1 b1 1a e1 00 00 00 00 00 00 00 00 00 00 00 00 >................<
000050 00 00 00 00 3e 00 03 00 fe ff 09 00 06 00 00 00 >....>...........<
000060 00 00 00 00 00 00 00 00 01 00 00 00 71 00 00 00 >............q...<
000070 00 00 00 00 00 10 00 00 73 00 00 00 01 00 00 00 >........s.......<
000080 fe ff ff ff 00 00 00 00 70 00 00 00 ff ff ff ff >........p.......<
000090 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >................<
*
000230 ff ff ff ff ff ff ff ff ff ff ff ff ec a5 c1 00 >................<
000240 07 80 19 04 00 00 f0 12 bf 00 00 00 00 00 00 10 >................<
000250 00 00 00 00 00 08 00 00 72 7b 00 00 0e 00 62 6a >........r{....bj<
000260 62 6a 2a 16 2a 16 00 00 00 00 00 00 00 00 00 00 >bj*.*...........<
000270 00 00 00 00 00 00 00 00 19 04 16 00 34 8e 00 00 >............4...<
000280 48 7c 00 00 48 7c 00 00 4b 2c 00 00 00 00 00 00 >H|..H|..K,......<
000290 19 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................<
0002a0 00 00 00 00 00 00 00 00 ff ff 0f 00 00 00 00 00 >................<
0002b0 00 00 00 00 ff ff 0f 00 00 00 00 00 00 00 00 00 >................<
0002c0 ff ff 0f 00 00 00 00 00 00 00 00 00 00 00 00 00 >................<
0002d0 00 00 00 00 b7 00 00 00 00 00 3e 0e 00 00 00 00 >..........>.....<
0002e0 00 00 3e 0e 00 00 a0 1b 00 00 00 00 00 00 a0 1b >..>.............<
0002f0 00 00 00 00 00 00 a0 1b 00 00 00 00 00 00 a0 1b >................<
000300 00 00 00 00 00 00 a0 1b 00 00 14 00 00 00 00 00 >................<
000310 00 00 00 00 00 00 ff ff ff ff 00 00 00 00 b4 1b >................<
000320 00 00 00 00 00 00 b4 1b 00 00 00 00 00 00 b4 1b >................<
000330 00 00 38 00 00 00 ec 1b 00 00 84 00 00 00 70 1c >..8...........p.<
000340 00 00 34 00 00 00 b4 1b 00 00 00 00 00 00 b8 28 >..4............(<
000350 00 00 e6 01 00 00 a4 1c 00 00 00 00 00 00 a4 1c >................<
000360 00 00 00 00 00 00 a4 1c 00 00 00 00 00 00 a4 1c >................<
000370 00 00 00 00 00 00 a4 1c 00 00 00 00 00 00 d8 1d >................<
000380 00 00 00 00 00 00 d8 1d 00 00 00 00 00 00 d8 1d >................<
000390 00 00 00 00 00 00 43 28 00 00 02 00 00 00 45 28 >......C(......E(<
0003a0 00 00 00 00 00 00 45 28 00 00 00 00 00 00 45 28 >......E(......E(<
*
0003c0 00 00 00 00 00 00 45 28 00 00 00 00 00 00 9e 2a >......E(.......*<
0003d0 00 00 a2 02 00 00 40 2d 00 00 da 00 00 00 45 28 >[email protected](<
0003e0 00 00 2d 00 00 00 00 00 00 00 00 00 00 00 00 00 >..-.............<
0003f0 00 00 00 00 00 00 a0 1b 00 00 00 00 00 00 d8 1d >................<
000400 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................<
000410 00 00 00 00 00 00 d8 1d 00 00 00 00 00 00 d8 1d >................<
000420
|
Depending on the encoding used to create the zip file, you might be able to prevent unwanted translations by temporarily setting the locale to "C":
LC_ALL=C 7z x $archive
(This helped for a zip created by IZArc on Win7, using two of your example filenames.)
However, for the archive in the question, the "filename" field contains the CP1251 encoding of "ДКП.doc" (84 8a 8f 2e 64 6f 63). The "extra" field uses an Info-zip extension (see section 4.6.9 of the Zip Specification v 6.3.4 ) to store the UTF-8 filename. unzip knows about this header, and uses the UTF-8 name, ignoring the CP1251 one.
7z doesn't do anything with this "extra field", and only uses the CP1251 one. Depending on the current locale, it might create the file using that exact name (the raw bytes 84 8a 8f), or worse, treat them as unicode points to be expanded to UTF-8 first (c2 84 c2 8a c2 8f).
One option is to use external utilities to change the zip first:
#!/bin/bash
cp orig.zip renamed.zip
index=0
zipinfo -1 orig.zip | while read name ; do
ziptool renamed.zip rename $index "$name"
index=$((index+1))
done
ziptool is from libzip. zipinfo is distributed with Info-ZIP's UnZip, so you might as well have just used unzip.
| How to specify character encoding for 7z? |
1,364,611,182,000 |
Because of specifics of my archiving needs I am not comfortable with solid tar.gz archives and use 7z instead.
I use the following command to do this:
7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=off ~/my/folder.7z ~/my/folder/*
To create an archive of everything inside ~/my/folder/ as the ~/my/folder.7z file.
But ~/my/folder/.hiddenFolder doesm't get into the archive then. How to fix this? Isn't * supposed to return all the files and folders?
|
If you want the contents of a single directory, an easy method is to change to it first:
cd ~/my/folder
7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=off ~/my/folder.7z .
What you saw is that * expands to the list of names of files that don't begin with a .. That's the documented behavior, and it's the main reason why files whose name begins with a . are said to be hidden (the other is that ls doesn't show them by default).
There's no really convenient portable way to list all files in a directory. You can use
~/my/folder/..?* ~/my/folder/.[!.]* ~/my/folder/*
but if there is no file matching one of the patterns then the pattern will remain unexpanded. In bash, you can set the dotglob option to avoid treating a leading . specially (. and .. are still excluded from the matches):
shopt -s dotglob
7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=off ~/my/folder.7z ~/my/folder/*
In ksh, or in bash if you set the extglob option (or in zsh if you set the ksh_glob option), you can write a pattern that matches all files except . and ..:
7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=off ~/my/folder.7z ~/my/folder/@(..?*|.[!.]*|*)
In zsh, there's a simpler way of saying that . must not be treated specially in a pattern:
7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=off ~/my/folder.7z ~/my/folder/*(D)
| How to use 7z to archive all the files and directories (including hidden ones) in a directory? |
1,364,611,182,000 |
I have a .7z file which I need to extract the contents of. The problem is, that it's password protected and currently, I have to SSH into the server and enter the password. I would like to this without the need of this.
Is this possible?
I have tried:
7za x file.7z -ppassword pass
But does not work, just returns "No files to process"
|
This is a year+ late, but in case anyone else googles this, use:
7za x file.7z -p'your_password'
Wrapping the password in single quotes does the trick
| 7za - Extract file with password |
1,364,611,182,000 |
How can I safely and quickly repack a zip archive to a 7zip archive?
I checked options of 7zip program but I don't see any option to repack. I know I can extract to directory and then pack this directory but is it safe? What if ZIP has paths like "../../file.exe" or "/etc/bin/file.exe"?
I tried unpacking files to stdout and while program 7zip can do this it outputs just content of files without their names etc. so I cannot just grab this output and redirect somewhere to pack into a 7zip archive.
|
You'll need to extract them to a temporary directory.
According to unzip (1),
For security reasons, unzip normally removes "parent dir" path components ("../") from the names of extracted file. This safety feature (new for version 5.50) prevents unzip from accidentally writing files to "sensitive" areas outside the active extraction folder tree head.
So while it is likely safe, your resulting 7z might have the files arranged differently, or even missing if filenames are duplicated.
Here's an example script, but it ignores the .. and absolute path issues:
#!/bin/sh
set -e
if [ "$1" == "" -o "$2" == "" ]
then
echo Usage: $0 archive.zip archive.7z
exit 1
fi
scratch=`mktemp -d`
trap "rm -rf $scratch" EXIT
in=`readlink -f $1`
out=`readlink -f $2`
if [ -f $out ]
then
echo $out exists.
exit 2
fi
unzip -d"$scratch" "$in"
cd "$scratch"
7z a "$out" .
| How can I repack zip to 7zip? |
1,364,611,182,000 |
I have a directory test with three files, ls -l test:
total 8
-rw-r--r-- 1 mb mb 16 Jul 25 11:12 regular_file
-rwxr-xr-x 1 mb mb 19 Jul 25 11:02 script.sh
lrwxrwxrwx 1 mb mb 12 Jul 25 11:14 symlink -> regular_file
It contains a regular file, a symbolic link, and an executable script.
After archiving this directory with tar -czf test.tgz test/, I wanted to extract the three files with 7-Zip:
7z x -tgzip test.tgz && 7z x -ttar test.tar
Unfortunately, 7-Zip doesn't produce the original files: The script loses its executable bit and symlink is not a symbolic link anymore, rather a file containing the text regular_file.
total 12
-rw-r--r-- 1 mb mb 16 Jul 25 11:12 regular_file
-rw-r--r-- 1 mb mb 19 Jul 25 11:02 script.sh
-rw-r--r-- 1 mb mb 12 Jul 25 12:16 symlink
On the other hand, I can extract the files with their permissions and the symlink intact using
tar -xzf test.tgz
Is there a way to make 7-Zip extract the files as they were before archiving them?
7-Zip version is 16.02. I'm on Arch Linux 5.7.7.
Here's the archive created with tar.
|
This seems to be a limitation of 7-Zip, judging from these bug reports:
#1302 .tar archives fail to extract properly
#1188 symlinks in tar archives are extracted to 0 byte files
For now, I'll keep using tar -xzf test.tgz to extract the files.
| Preserve file permissions and symlinks in archive with 7-Zip |
1,364,611,182,000 |
How can I check if a file is an archive and then extract it with 7z? I understand that I could check it by file command but it won't work in scripts because of its output. I can't predict what type of archive it could be. I just want to do something like:
Can I extract it by 7z?
If yes, extract,
if not, go further
by bash sript.
|
The 7z utility returns a non-zero exit code if the operation it performs fails. You can use this fact to try to extract the archive and then do something else if that fails:
if ! 7z e filename 2>/dev/null; then
# do something else
fi
or, depending on what else you want to do, or not do,
if 7z e filename 2>/dev/null; then
exit
fi
# do something else
which may be shortened to
7z e filename 2>/dev/null && exit
# do something else
You could obviously wrap this in
if 7z t filename; then
fi
and catch a failure of extraction (due to not enough disk space or whatever other error might occur during extraction) separately from a failure of determining that this is indeed a 7z archive.
The full code may look like
if 7z t filename 2>/dev/null; then
if 7z e filename 2>/dev/null; then
echo 'All is good, archive extracted' >&2
else
echo 'Archive failed to extract' >&2
fi
else
echo '7z failed to process the file' >&2
fi
| Check if file is an archive; if yes, extract |
1,364,611,182,000 |
I've been attempting to compress my mysqldump output via 7z using the pipe operator (I have seen this question, but its answer uses xz not 7z). This is what I have tried so far:
mysqldump -u root -p Linux_Wiki | 7z > backup.sql.7z
and:
mysqldump -u root -p Linux_Wiki | 7za > backup.sql.7z
and:
mysqldump -u root -p Linux_Wiki | '7za a' > backup.sql.7z
and:
mysqldump -u root -p Linux_Wiki | `7za a` > backup.sql.7z
All four failed, but I am sure I have p7zip installed, after all the last of these attempts gave this output:
Enter password: bash: 7-Zip: command not found
mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: NO) when trying to connect
|
First store the password in a file called .my.cnf in the users home directory with the following format:
[mysqldump]
password=secret
Then, you have to use mysqldump without the -p flag to dump a mysql database (it now uses the password from the file):
mysqldump -u root database | 7z a -si backup.sql.7z
The a flag of 7z adds to the archive
-si means to read from the standard input (from the anonymous pipe).
| How to compress a mysql dump using 7z via a pipe? |
1,364,611,182,000 |
When creating a 7zip archive with file-roller, there is a checkbox labeled "Encrypt the file list too". And it seems to work as you cannot see the file list when opening an archive created with this checkbox ticked until you enter the password (which you are immediately prompted for when opening the archive), whereas you can see the file list and only are prompted the enter the password upon trying to access the files in the archive.
From 7zip's man page, I know that one can create an encrypted archive by passing the p switch. But the file lists of those archives aren't encrypted.
How do I encrypt the file list of a 7zip archive when creating it from the command line?
|
From the manual page for 7z:
-mhe=on|off
7z format only : enables or disables archive header encryption (Default : off)
| Encrypt file list when creating 7zip archive on command line |
1,364,611,182,000 |
As I don't use GUI for archive extraction much, I don't know since when this error I am getting:
An error occurred while loading the archive.
This error I get while trying to open an ordinary Zip and / or 7z archives, but I care only about Zip in this question.
I am able to open tar.bz2 and tar.gz files, though.
As a side note: This is particularly annoying as I started using Thunderbird for mail and so I intend to open all attachments in GUI.
OS and DE: Linux Mint 18.1 Cinnamon 64-bit.
Version of Archive manager for GNOME:
/usr/bin/file-roller --version
file-roller 3.16.5, Copyright © 2001-2012 Free Software Foundation, Inc.
Example:
A file downloaded from GitHub from this page as Zip: TrueColour.md
For convenience renamed to truecolor.zip.
file truecolor.zip
says it is an ordinary Zip archive:
truecolor.zip: Zip archive data, at least v1.0 to extract
file-roller truecolor.zip
run from terminal says the above error message with no output to the terminal.
Sure though, I am able to decompress it with:
unzip truecolor.zip
with output:
Archive: truecolor.zip
f8e6e08a0f0d3ad09e599a4f17edc010d38e4ec8
creating: 8346728-f8e6e08a0f0d3ad09e599a4f17edc010d38e4ec8/
inflating: 8346728-f8e6e08a0f0d3ad09e599a4f17edc010d38e4ec8/TrueColour.md
EDIT1:
I have managed to get some, possibly useful, debug info using:
strace -t -f file-roller truecolor.zip 2> fileroller-open-zip-strace
As it is rather lengthy, it won't fit into Pastebin, so I have compressed it, SHA-256 hash follows:
4f09bc1f16c0e618cfd6937946db23a18be8e5e1fb1b8d4930ead49af5e77abb
You may download it from my hosting:
https://www.vlastimilburian.cz/fileroller-open-zip-strace.bz2
The above file has been deleted.
If someone knows what to look for in the strace's output, I am sure he / she would find the relevant part, but I sadly don't know what to look for.
EDIT2:
Latest available version on GitHub, compiled:
./file-roller --version
file-roller 3.22.2, Copyright © 2001-2012 Free Software Foundation, Inc.
run from terminal:
./file-roller ~/Downloads/truecolor.zip
shows the very same error message:
An error occurred while loading the archive.
|
I had to self-compile the p7zip package, now everything works as usual.
I tried purging p7zip-full and installing it back, but that didn't do anything, I still wonder why. Nevermind, solution was to build the package myself, I should have done that long time ago.
| file-roller: An error occurred while loading the archive (Zip/7z) |
1,364,611,182,000 |
With the commands md5sum, sha1sum, sha256sum I can take a text file having an hash and a path per line and verify the entire list of files in a single command, like sha1sum -c mydir.txt. (Said text file is easy to produce with a loop in find or other.)
Is there a way to do the same with a list of CRC/CRC32 hashes?
Such hashes are often stored inside zip-like archives, like ZIP itself or 7z. For instance:
$ unzip -v archive.zip
Archive: archive.zip
Length Method Size Cmpr Date Time CRC-32 Name
-------- ------ ------- ---- ---------- ----- -------- ----
8617812 Stored 8617812 0% 12-03-2015 15:20 13fda20b 0001.tif
Or:
$ 7z l -slt archive.7z
Path = filename
Size = 8548096
Packed Size =
Modified = 2015-12-03 14:20:20
Attributes = A_ -rw-r--r--
CRC = B2F761E3
Encrypted = -
Method = LZMA2:24
Block = 0
|
Try RHash
Try RHash.
There are packages for
Cygwin, Debian.
Example
$ echo -n a > a.txt; echo -n b > b.txt; echo -n c > c.txt
✔
$ rhash --crc32 --simple *.txt > checksums.crc32
✔
$ cat checksums.crc32
e8b7be43 a.txt
71beeff9 b.txt
06b9df6f c.txt
✔
$ rhash --crc32 --check checksums.crc32
--( Verifying checksums.crc32 )-------------------------------------------------
a.txt OK
b.txt OK
c.txt OK
--------------------------------------------------------------------------------
Everything OK
✔
Note 1: --simple format
If you don't use the --simple formatting option then rhash will default to a different format. And this may not be what you want:
$ rhash --crc32 *.txt
; Generated by RHash v1.3.7 on 2020-06-03 at 16:02.51
; Written by Kravchenko Aleksey (Akademgorodok) - http://rhash.sf.net/
;
; 1 15:58.36 2020-06-03 a.txt
; 1 15:58.36 2020-06-03 b.txt
; 1 15:58.36 2020-06-03 c.txt
a.txt E8B7BE43
b.txt 71BEEFF9
c.txt 06B9DF6F
✔
Note 2: --all option
If you wanna go crazy: try the --all option to get ALL supported hashes at once.
| Command to verify CRC (CRC32) hashes recursively |
1,364,611,182,000 |
The man page says 7z tool supports 7z, LZMA2, XZ, ZIP, Zip64, CAB, RAR, ARJ, GZIP, BZIP2, TAR, CPIO, RPM, ISO, most filesystem images and DEB formats.
And it says we could pass the type as -t{Type}. The following command is success.
7z a -tzip archive.zip dir1 dir2 file1 file2
But I can't archive the files into .xz using the following command.
7z a -txz archive.zip dir1 dir2 file1 file2
$ 7z a -txz archive.xz dir1 dir2 file1 file2
7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_GB.UTF-8,Utf16=on,HugeFiles=on,64 bits,4 CPUs Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz (806E9),ASM,AES-NI)
Scanning the drive:
2 folders, 7 files, 196192711 bytes (188 MiB)
Creating archive: archive.xz
Items to compress: 9
System ERROR:
E_INVALIDARG
Anything I am doing wrong here? How to create .xz file using 7z command?
EDIT:
The following command successful.
7z a -txz archive archive.tar
Does it mean we can use -txz or -tbzip2 on only archive files as we can't directly use compression on files without archiving the files first?
|
Like gzip (.gz) and bzip2 (.bz2), but unlike zip and rar, xz is a compression format, not an archive format. You can compress one file:
7z a -txz foo.xz foo
This is equivalent to xz foo.
Typically, to make a compressed archive, you make a tar archive and compress it. You can make a compressed archive with 7z, but as far as I can tell, you can't do it in a single step: you have to create the tar first, then compress it. (7z does know how to read from a compressed archive directly.) You can do that in a pipeline.
set -o pipefail
7z a -ttar -so archive.tar.xz dir1 dir2 file1 file2 | 7z a -txz -si archive.tar.xz
As far as I know, archive.tar.xz in the left-hand command is ignored (-so tells 7z to write to standard output), but it's still necessary.
With a pipeline, beware that in sh, if the tar creation fails, for example because a file can't be read, then the pipeline command won't fail. Ksh, bash and zsh have an option pipefail to make the whole command fail.
It's a lot simpler to call tar directly. Most modern tar implementations can create gz, bz2 and xz compressed archives.
tar -cJf archive.tar.xz dir1 dir2 file1 file2
| 7z command to create a XZ file |
1,364,611,182,000 |
I have about two hundred sub-directories located within a directory of interest:
$ ls backup
201302
201607
201608
201609
201610
201701
201702
201705
201801
201802
I want to create a 7z archive xyz.7z for each directory xyz:
cd $HOME/backup/
7z a "storage/nas/TBL/compressed_backups/$xyz.7z" "$xyz" -mmt=4
So in the end I will have these archives in storage/nas/TBL/compressed_backups:
201302.7z
201607.7z
201608.7z
201609.7z
201610.7z
201701.7z
201702.7z
201705.7z
201801.7z
201802.7z
Additionally I want to use parallel in order to process five directories at a time. (I have enough computing power for this purpose)
parallel -j5 ::: 7z a "storage/nas/TBL/compressed_backups/$xyz.7z" "$xyz" -mmt=4
How can I wrap this all up together?
|
Use the following approach:
ls backup | parallel -j5 7z a -mmt=4 "storage/nas/TBL/compressed_backups/{}.7z" {}
{} - input line. This replacement string will be replaced by a full line read from the input source.
| Create separate 7z archives for each directory in the current directory and additionally parallelize through GNU Parallel |
1,364,611,182,000 |
7zips context menu appears twice to me when I right-click to a file.. Same thing happens in both dolphin and krusader. It looks like this:
I've found 7zips readme.txt in /usr/share/kde4/services/ServiceMenus/ and this is one of the things in it:
3) installing the context menu for KDE (dolphin or konqueror)
(tested on Ubuntu 10.10)
--------------------------------------------------
for all:
cp GUI/kde4/*.desktop /usr/share/kde4/services/ServiceMenus/
these are the 7zip files in that are located in that folder at the moment:
p7zip_compress2.desktop
p7zip_compress.desktop
p7zip_extract.desktop
p7zip_extract_subdir.desktop
p7zip_extract_to.desktop
p7zip_test.desktop
I guess some of them are extra but I am not sure which ones can be removed.
I am using Arch with KDE and the packages are at the most recent versions. Did anyone else encounter this problem? Does anyone have an idea how to solve it so it would appear only once? I've been having this problem for a few months now (since I installed 7zip actually).
|
I had the same problem and your question actually helped me out a lot. I tried to delete the first one (p7zip_compress2) after I checked that inside the file it had the same entries as the rest of the .desktop files... So delete it and solved! no need to restart or anything
| 7zip context menu appears twice |
1,364,611,182,000 |
I want to get the number of files (included directories) contained in the root of a 7z archive, but the 7z command on Linux don’t bring a simple way to only get the number and noting else.
For example I have the 7zarchive.7z file witch contain archive.tar and archive.gzip. Then, 7z l 7zarchive.7z print me the following verbose lines:
7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
p7zip Version 9.20 (locale=fr_FR.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)
Listing archive: 7zarchive.7z
--
Path = 7zarchive.7z
Type = 7z
Method = LZMA
Solid = +
Blocks = 1
Physical Size = 495
Headers Size = 184
Date Time Attr Size Compressed Name
------------------- ----- ------------ ------------ ------------------------
2016-03-14 22:43:10 ....A 20480 311 archive.tar
2016-03-14 23:04:01 ....A 163 archive.gzip
------------------- ----- ------------ ------------ ------------------------
20643 311 2 files, 0 folders
In the right bottom, you can see “2 files, 0 folders”, so I want to get the sum of number of folders and number of files.
For this, I try the flowing hideous command :
bash
7z l 7z l *.7z | tail -1 | sed -e 's/.* \([0-9]*\) files\, \([0-9]*\) folders/\1 \2/' -e 's/\([0-9]*\) \([0-9]*\)/\$(( \1 + \2))/' | tail -1 | sed -e 's/.* \([0-9]*\) files\, \([0-9]*\) folders/\1 \2/' -e 's/\([0-9]*\) \([0-9]*\)/\$(( \1 + \2))/'
tail extract the last line;
The first sed expression extract the numbers before the words “files” and “folders”.
The second sed expression formate it to be printed like this $(( <first number> + <second number>)).
So, I really obtain the output $(( 2 + 0)), but I want it to be executed to get only the result (2) and not the command to calculate the result.
So, there is a way to do this, or, at list, a more simple way to get the number of files contained by a 7z archive?
|
I finally find it, it was more simple that I imagine: 7z l -slt <nameof archive> | grep -c 'Path = [^/]*$'.
| How to get number of files in a 7z |
1,364,611,182,000 |
As in title. I've got a lot of ZIP archives that I want to extract.
All archives have their own unique name.
All archives contain files only (inside archives there are NOT folder(s) at all: no parent / main folder).
I'd like to process all these ZIP archives via GNU parallel.
To sum up:
archivename(s).zip has NOT folder(s) inside
extract content of archivename(s).zip into archivename(s)/ folder (this folder needs to be created!)
keep archivename(s).zip after extracting it
repeat this for all the ZIP archivename(s).zip
I was wondering about what utility fits best ZIP extraction: gunzip? unzip? bsdtar? 7z?
P. S.: I'd like to take advantage of GNU parallel for speeding up the whole operation (I'm using SATA SSD devices).
|
Removing file extension when processing files:
parallel 'mkdir {.} && cd {.} && unzip ../{}' ::: *.zip
| GNU parallel + gunzip (or 7z, or bsdtar, or unzip): extract every "archivename.zip" into (to-be-created) its "archivename" subfolder |
1,364,611,182,000 |
I'm trying to decompress a big zip file containing more that a hundred files, 128 MB each. When the decompression is interrupted, I have to delete the last file that was being decompressed, and restart all over with the option to skip existing files enabled, like so:
unzip -n my_compressed_file.zip -d destination
Is there a way to decompress zip files so that only those fully decompressed files appear in the destination directory?
|
You could write a wrapper script that extracts the files to a temporary location, and only moves them to their final destination when they are complete. Something like
tempdir="incomplete/"
mkdir -p "$tempdir"
zipinfo -1 compressed.zip | while read f ; do
test -f "$f" && continue # skip anything extracted by a previous attempt
printf "extracting %s..." "$f"
unzip -p compressed.zip "$f" > "$tempdir/$f"
printf "done!\n"
mv "$tempdir/$f" "$f"
done
rm -r "$tempdir"
If this is interrupted, then you'll still have a partial file, but when you run it again, it will skip complete files (in their correct location) and immediately overwrite the partial one (in the temporary directory). When it finally reaches the end of the archive, it will remove the temporary directory entirely.
There are some limits to my example script. It assumes that the zip doesn't contain a directory structure of its own, and uses the temporary directory incomplete/ inside the working folder. If this is unacceptable, you'd have to
use another value for tempdir, that is somewhere on the same filesystem (to permit atomic mv) and is guaranteed not to be used by any other process, and
add an additional mkdir step, inside the loop, to reconstruct the extracted directory structure
See also Is mv atomic on my fs?
| How to obtain only fully decompressed files in destination folder when decompressing zipped file? |
1,364,611,182,000 |
I'm trying to make a bash script that takes a large number of 7z archives and combines them into one archive. Here's what I have so far.
#!/bin/bash
DUMPPATH="/home/backups/dumps/"
NEWPATH=$DUMPPATH"combined/"
FILETYPE="*.7z"
DATE="$(date +%Y-%m-%d-%H-%M-%S)"
NEWNAME=$NEWPATH"AllAsOf"$DATE".7z"
for FILE in $(ls $DUMPPATH$FILETYPE)
do
echo -n $FILE"..."
7z e $FILE -so | 7z a -si -mx=9 $NEWNAME
if [ $? -eq 0 ]; then
echo "Done."
else
echo "Something broke"
exit
fi
done
When I ran the script I got Error: Duplicate filename, so I tried to run just the guts of the script:
7z e /home/backups/dumps/foo.7z -so | 7z a -si -mx=9 /home/backups/dumps/combined/combined.7z . I looked inside combined.7z, and it contains a file called combined. The reason my script wasn't working is that each file being added to combined.7z is being added with as the same filename.
I think I need to specify the filename inside that 7z adds each file as because it's getting its data from stdin. Is there a way to do that?
|
I learned from this question that I can add the file name after the -si flag in 7z. I added a line to get the filename, also. My script became:
#!/bin/bash
DUMPPATH="/home/backups/dumps/"
NEWPATH=$DUMPPATH"combined/"
FILETYPE="*.7z"
DATE="$(date +%Y-%m-%d-%H-%M-%S)"
NEWNAME=$NEWPATH"AllAsOf"$DATE".7z"
for FILE in $(ls $DUMPPATH$FILETYPE)
do
echo -n $FILE"..."
THISNAME=$(echo $FILE | sed "s|.*"$DUMPPATH"||" | sed "s/\.7z.*//")
7z e $FILE -so | 7z a -si$THISNAME -mx=9 $NEWNAME
if [ $? -eq 0 ]; then
echo "Done."
else
echo "Something broke"
exit
fi
done
I know there's a better way to do that regex, but this works.
| How can I combine multiple 7z archives into one? |
1,364,611,182,000 |
I accidentally typed
7z e archive.7z
and all the files ended up in my home directory when I wanted to extract them in a subfolder. How can I clean the mess and remove all those files?
|
Looking at this answer and that one in particular, I ended up running this command which removed all the unwanted files:
7z l archive.zip | awk ' {print $6} ' | awk '
function basename(file) {
sub(".*/", "", file)
return file
}
{print basename($1)} ' | xargs rm -rf
| How to undo and revert an accidental `7z e` |
1,364,611,182,000 |
Using 7z, I'd like to print the names of the files inside an archive.
The output of 7z l myArchive.7z is
7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.utf8,Utf16=on,HugeFiles=on,64 bits,4 CPUs Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz (206A7),ASM,AES-NI)
Scanning the drive for archives:
1 file, 171329 bytes (168 KiB)
Listing archive: myArchive.7z
--
Path = myArchive.7z
Type = 7z
Physical Size = 171329
Headers Size = 237
Method = LZMA2:18
Solid = +
Blocks = 1
Date Time Attr Size Compressed Name
------------------- ----- ------------ ------------ ------------------------
2020-06-05 16:03:29 ....A 0 0 file with spaces
2020-06-05 11:53:13 ....A 96616 171092 screen_2020-06-05_11-53-13.png
2020-06-05 11:53:43 ....A 106932 screen_2020-06-05_11-53-43.png
------------------- ----- ------------ ------------ ------------------------
2020-06-05 16:03:29 203548 171092 3 files
I'd like to make 7z print only the file names:
file with spaces
screen_2020-06-05_11-53-13.png
screen_2020-06-05_11-53-43.png
Is there a way to do that?
|
Just use libarchive's bsdtar:
bsdtar tf file.7z
Also note that 7z l would prompt you for a password if the archive is encrypted while bsdtar will just return with an error which would be preferable in scripts.
| How to get file names in archive with 7z |
1,364,611,182,000 |
I am on Linux Mint 18 Cinnamon 64-bit.
I have these binaries of 7z and their versions on my system:
/usr/bin/7z
7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
and
/usr/local/share/PeaZip/res/7z/7z
7-Zip [32] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
As I am always using the latter, it is becoming increasingly annoying to write full path to it.
Shall I just define an alias or there is a cleaner way?
|
A way of replacing a binary with another in Debian such that it survives updates on the packages (for instance, replacing the init file of a BIND package), is doing a file diversion.
Basically a file diversion install/moves the original file to another location, and instructs the package manage system to place any subsequent install updates to that file in the new location, leaving untouched the original location.
As per the Debian policy manual - diversions, in your case:
dpkg-divert --divert /usr/local/share/PeaZip/res/7z/7z.old --rename /usr/bin/7z
cp /usr/local/share/PeaZip/res/7z/7z /usr/bin/7z
To remove the diversion:
dpkg-divert --remove /usr/bin/7z
Make backup copies of both the binaries before trying the diversion.
For more commands see: Replace binaries and Files with dpkg-divert
Another easier alternative is holding the original package e.g. telling the package manager to not apply updates to it, and copying over the new binary as in:
echo "p7zip hold" | dpkg --set-selections
or simplier:
apt-mark hold p7zip
See: How to prevent a package from being updated in Debian
Another yet cleaner option would be building a deb with the new p7zip version, however as the method and specific steps vary with the packages, I won't try to describe it here.
| What is the proper way to use an alternative binary |
1,364,611,182,000 |
Until now, I used to backup my data using tar with one of the LZMA compression options (--lzma, --xz or --lzip)
I recently noticed that 7-Zip has been ported to Linux in 2021 (https://www.xda-developers.com/7-zip-linux-official-release/). I'm not talking about the older P7Zip (https://p7zip.sourceforge.net/), that doesn't seem to be maintained anymore, but about the official 7-Zip.
So, I tested it, and was very surprised to discover that it's A LOT faster than all the others Linux LZMA implementations, for the same compression ratio.
Below my tests (Debian 11). Please not that I emptied the RAM cache between every test (sync && echo 3 > /proc/sys/vm/drop_caches)
I am working on a 163M folder, containing several type of files, PDF, text, open office, and so on...
$ du -hs TEST/
163M TEST/
With 7-Zip it's compressed into a 127M file in 15 seconds :
$ time tar c -hp TEST/ | 7zz a -si test.tar.7z
real 0m14,565s
(...)
$ ll test.tar.7z
(...) 127M (...) test.tar.7z
Whereas with all the other implementations of LZMA, it takes almost 5 times longer (around 1'13"), for the same archive size !
$ time tar -chp --lzma -f test.tar.lzma TEST/
real 1m13,159s
$ time tar -chp --xz -f test.tar.xz TEST/
real 1m12,889s
$ time tar -chp --lzip -f test.tar.lz TEST/
real 1m12,525s
$ ll test.tar.{7z,lz*,xz}
(...) 127M (...) test.tar.7z
(...) 127M (...) test.tar.lz
(...) 127M (...) test.tar.lzma
(...) 127M (...) test.tar.xz
Just to be sure there's nothing wrong with tar, I did the same tests but piped tar's output to lzma|xz|lzip, instead of using the --lzma, --xz and --lzip switches. Same results.
So, basically, 7-Zip's Linux version makes all other LZMA implementations look rather bleak. I think 7-Zip doesn't support Linux owners and permissions, but that's irrelevant when compressing a .tar file.
So, does anybody know why 7-Zip's Linux version is so much faster than other LZMA implementations ?
|
7zz uses hand-written assembly, p7zip and xz do not.
Besides, XZ's LZMA implementation is very dated. Igor Pavlov has made a ton of changes in 7-zip to speed it up in the last seven years.
| Why is 7-zip much faster than other LZMA implementations in Linux? |
1,364,611,182,000 |
I did quite a bit of searching before asking this! (Even so I'm expecting to have a duplicate pointed out).
So I collect a bunch of files, e.g.:
find . -name "2020-*"
... is there some way to "pipe" all these files into a .7z archive? (NB I realise "pipe" may not be the right word as the operation I want is in fact a file-copy operation).
I've tried things like:
find . -name "2020-*" | 7z a -p pumple.7z
... this gives me ">" on the next line, as though it's expecting some console input.
So does the following:
find . -name "2020-* > 7z a -p pumple.7z
|
You need to provide the file names as arguments to 7z:
find . -name '2020-*' -exec 7z a -p pumple.7z {} +
This tells find to look for files (of any type) whose name matches 2020-*, and when it finds such files, run 7z a -p pumple.7z followed by the names of the files. The {} is the placeholder for the file names, and + tells find to run the command with as many file names as possible in one go.
| Add files from "bash find" to 7z archive |
1,444,231,093,000 |
How can I create a Wi-Fi hotspot with the command line tool nmcli and share/bridge the ethernet internet connection with the wireless access point? Furthermore, how can I start this automatically at boot?
Is this possible with nmcli?
|
I created a Hotspot with the GNOME Network-Manager. The problem was, that I can not configure the SSID and password in GUI. If you create the Hotspot with the Network-Manager GUI, it creates the file /etc/NetworkManager/system-connections/Hotspot. In that file it is possible to edit the SSID and the password.
sudo vim /etc/NetworkManager/system-connections/Hotspot
The content of the file looks like this:
[connection]
id=Hotspot
uuid=0bf627gd-8e34-48c6-865a-06f898b4y1hb
type=wifi
autoconnect=true
permissions=
secondaries=
[wifi]
hidden=false
mac-address=YOUR_WIFI_INTERFACE_MAC_ADDRESS
mac-address-blacklist=
mode=ap
seen-bssids=
ssid=SSID_NAME
[wifi-security]
group=ccmp;
key-mgmt=wpa-psk
pairwise=ccmp;
proto=rsn;
psk=YOUR_WIFI_AP_PASSWORD
[ipv4]
dns-search=
method=shared
[ipv6]
dns-search=
method=auto
I changed the ssid and the psk properties to my needs. To enable autostart you have to set the parameter autoconnect to true. Then I restarted my computer because the command: sudo systemctl restart NetworkManager for network restart seems not to work correctly, because in the Network-Manager GUI:
I have no wireless network settings anymore and also the following command worked not before the restart. After restart you can use the nmcli command to start the access point.
nmcli con up Hotspot ifname YOUR_WIFI_INTERFACE
YOUR_WIFI_INTERFACE you can find out with the command iwconfig.
I used Antergos / Arch Linux for the above solution and found the hint to this at the ask.fedoraproject.org site.
| Create wireless access point and share internet connection with nmcli |
1,444,231,093,000 |
As we know, We can create virtual wireless interface using iw dev (1). Also, We can change it's MAC address using ifconfig <ifname> hw ether <Address>. Then We can Set two different access points (SSIDs) to each of these inetrfaces using Network Manager.
For example:
(Real) wlan0: 00:16:b6:ab:cd:e7 -> AP(1)
(Virtual) wlan1: 00:16:b6:ab:cd:e8 -> AP(2)
But whenever wlan0 is connected to AP(1), And I try to connect to AP(2), First the wlan0 disconnects and then wlan1 connects to it's own AP.
I need to connect both of them simultaneously. Is it possible? How?
Edit: My specific card is a Lisco/Linksys RTL8191SEvB. I run Linux 4.4.38.
|
Some(Most in 2021?) Wifi-chips can function in several modes at the same time, but all on the same frequency, because they use the same radio. Now, If you have 2 radios attached to your chip, you could have several functions on several frequencies/channels.
Update 2021: Some cards can work on 2 Channels at the same time. These are 2.4/5Ghz combination devices, and most of those can do 1 of the 2.4, and another 1 from the 5Ghz Channels at the same. Some devices received this function via a FW upgrade, e.g. some Intel Cards.
Some other cards, like the one the PI ZeroW, can do 2 channels in the 2.4Ghz group at the same time.
E.g. the Intel 3160 can be 1 station, 1 Access-Point, AND 1 P2P device at the same time. This is used for WiDi or Miracast, while still being connected to the "other" Network.
The valid combinations for your chip can be seen as root with:iw list | grep -A 8 'interface combination'
Some examples:
Intel 3160:
valid interface combinations:
* #{ managed } <= 1, #{ AP, P2P-client, P2P-GO } <= 1, #{ P2P-device } <= 1,
total <= 3, #channels <= 2
Qualcomm Atheros QCA986x/988x 802.11ac Wireless Network Adapter
* #{ AP, mesh point } <= 8, #{ managed } <= 1,
total <= 8, #channels <= 1, STA/AP BI must match
Qualcomm Atheros QCA9377 802.11ac Wireless Network Adapter (rev 31)
* #{ managed } <= 2, #{ AP, mesh point, P2P-client, P2P-GO } <= 2, #{ P2P-device } <= 1,
total <= 4, #channels <= 1
* #{ managed } <= 2, #{ P2P-client } <= 2, #{ AP, mesh point, P2P-GO } <= 1, #{ P2P-device } <= 1,
total <= 4, #channels <= 2
* #{ managed } <= 1, #{ IBSS } <= 1,
total <= 2, #channels <= 1
PI Zero Wireless
* #{ managed } <= 1, #{ P2P-device } <= 1, #{ P2P-client, P2P-GO } <= 1,
total <= 3, #channels <= 2
* #{ managed } <= 1, #{ AP } <= 1, #{ P2P-client } <= 1, #{ P2P-device } <= 1,
total <= 4, #channels <= 1
USB MediaTek Inc., driver mt76x0u
* #{ IBSS } <= 1, #{ managed, AP, mesh point, P2P-client, P2P-GO } <= 2,
total <= 2, #channels <= 1, STA/AP BI must match
rt2800usb reports:
* #{ AP, mesh point } <= 8,
total <= 8, #channels <= 1
rtl8192cu dongles, that use the same chip as your device, and most Realtek devices report:
interface combinations not supported
This message means, that your card can only perform 1 function at the same time.
For some wifi-chips several signed firmwares with differing capabilities are available. AFAICT, not for your rtl819x though.
For an Intel IWLWifi a solution could have been to switch (one of the) connections to you being the AP, or making it "Ad-Hoc"
Otherwise you'd have to replace your card with one that has #{managed}<5 or similarly relaxed restrictions.
Or, add a(nother) 10€ WUSB-WiFi-dongle for connection to the second AP.
| Single wifi card, Connect to multiple access points simultaneously |
1,444,231,093,000 |
(I was trying and trying for hours to find a workaround, which proved much harder than initially expected.)
The problem itself is easy to understand, though. I recently installed a GUI-less Debian derivative on one of my machines and configured /etc/wpa_supplicant/wpa_supplicant.conf to access one of my access points and that worked out well.
Soon I took my machine with me out of home, so I added another network (which is my phone in hotspot mode this time) to wpa_supplicant.conf.
Sadly I noticed that it doesn't automatically connect to the phone's AP even after losing connection to the inital router, followed by wpa_cli --reconfigure.
Funny part: uncommenting the first network in the wpa_supplicant.conf makes my phone's AP work flawlessly. If both networks are kept uncommented, only the first one works.
I was reading the whole manual of wpa_supplicant.conf but the closest thing to what I needed was the BSSID option which didn't help in this situation.
So my question: how do I make the network controller change access points depending on availability of these?
Update:
I don't have /usr/share/doc/wpa_supplicant/README.modes, but only /usr/share/doc/wpa_supplicant/README.modes.gz which I am unable to extract because of too many symbolic links.
My /etc/wpa_supplicant/wpa_supplicant.conf:
country=DE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="Klaus B. Schuldiger"
scan_ssid=1
psk="----"
}
#network={
#ssid="Xperia XZ_acd9"
#scan_ssid=1
#psk="----"
#}
|
To debug what wpa_supplicant is doing, wpa_cli status will give information about whether wpa_supplicant still thinks it's connected to an AP, or searching for a new AP.
Wpa_supplicant needs to be in roaming mode to automatically switch between networks. You enable roaming by using a wpa-roam entry after the iface stanza in /etc/network/interfaces, and put all the networks in a wpa_supplicant.conf file (typically /etc/wpa_supplicant/wpa_supplicant.conf). Details can be found in README.modes or README.modes.gz in the wpa_supplicant documentation.
Hidden access points (APs) will cause trouble for two reasons: One the hand, wpa_supplicant will be need to actively configured to scan for all of them (and I don't know the details on how to configure that). On the other hand, the WLAN client will have problems to determine if the connection is still valid or not, because the AP doesn't send out beacons which could be measured. So all the client sees is no answer to transmitted packets, which could also be caused by problems somewhere else in the network. The client will timeout the connection eventually, but that can take several minutes.
Also, hidden APs don't really improve security: Traffic between a hidden AP and a client can be sniffed, giving away the existence of the AP. A client actively scanning for an AP also gives away the existence (and as it's actively scanning for all hidden APs it knows of, it gives even more information).
So the easiest solution is to make all APs non-hidden in case they cause problems.
| wpa_supplicant doesn't auto-change AP |
1,444,231,093,000 |
I'm currently trying to set up an access point on my raspberry pi, but as soon as I install 'dnsmasq', the internet connection is lost ('unknown host' when trying to ping any server).
What causes this and how do I connect it to the internet again?
P.S.: i can access it via ssh, so local network is still working...
edit: so apparently it's just the dns-server, because it works when pinging the numeric ip instead of e.g. google.com; I assume the dnsmasq/nscd service is overwriting the working configuration
|
You need to configure dnsmasq. Look in /etc/dnsmasq.conf. I don't know much about your situation, but I'm certain that you'll need to set these options:
resolv-file=/etc/dnsmasq.resolv
listen-address=127.0.0.1
listen-address=10.0.0.3 # Or whatever the machine's IP address is.
The file /etc/resolv.conf is what every process other than dnsmasq looks into to find what IP address to send a DNS query to. On the machine running dnsmasq, /etc/resolv.conf should have it's own IP address in resolv.conf.
Then, you need to have /etc/dnsmasq.resolv containing the IP address of the next level up's DNS server. That might be your company's DNS server, or your ISP's DNS server, or something like 8.8.8.8, or whoever you use.
I have a superstition that after changing dnsmasq.conf or dnsmasq-resolv, you have to stop and start the dnsmasq process. I could be wrong.
| Internet connection lost after installing dnsmasq |
1,444,231,093,000 |
I have this network adapter in an Asus notebook running Manjaro Linux (based on Arch), everything up to date (Kernel: 3.10.11):
> lspci -k | grep -A 3 -i "network"
lspci: Unable to load libkmod resources: error -12
07:00.0 Ethernet controller: Qualcomm Atheros AR242x / AR542x Wireless Network Adapter (PCI-Express) (rev 01)
Subsystem: AzureWave AW-GE780 802.11bg Wireless Mini PCIe Card
Kernel driver in use: ath5k
iwconfig gives:
> iwconfig
wlp7s0 IEEE 802.11bg ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Power Management:off
I have hostapd 2.0 installed. My minimal config is:
interface=wlp7s0
driver=nl80211
hw_mode=g
ssid=test
channel=6
Running it gives
> hostapd test.conf
Configuration file: test.conf
Could not set interface wlp7s0 flags (UP): Operation not permitted
nl80211 driver initialization failed.
Running with sudo:
sudo hostapd test.conf
Configuration file: test.conf
nl80211: Failed to set interface wlp7s0 into AP mode
nl80211 driver initialization failed.
What is wrong here? How do I get my notebook to work as an AP?
|
Just found the answer myself (after googling hours to find the answer in a small but very important sentence in a private blog post about Ubuntu):
Disable (means stop the daemon or kill the process) networkmanager (or in some Distros network-manager) because it does take control over the (W)LAN Adapters, blocking it for other programs.
After doing this, hostapd can create the Access Point by initialising nl80211 correctly.
| hostapd, ath5k, nl80211 - how to get it working? |
1,444,231,093,000 |
I am trying to set up an AP using the following configuration:
Wi-Fi adapter: TP-Link AX3000 (Intel AX200 based)
Operating system: Ubuntu Server 20.10 (groovy)
Kernel version: 5.8.0-44-generic
Firmware: iwlwifi-cc-a0-55.ucode
AP service: hostapd v2.9 (tried the custom-build from the latest source code as well)
I have two almost identical setups in Canada and France. The one in Canada - works, the other one - no. As I tried to exclude any software configuration discrepancy, I ended up suspecting that this problem is somehow related to the regulatory domain. Below are the details from the failing setup.
As this setup is located in France, I set the regulatory domain respectively:
$ sudo iw reg set FR
Verifying it I get the following (initially):
$ sudo iw reg set
global
country FR: DFS-ETSI
(2400 - 2483 @ 40), (N/A, 20), (N/A)
(5150 - 5250 @ 80), (N/A, 23), (N/A), NO-OUTDOOR, AUTO-BW
(5250 - 5350 @ 80), (N/A, 20), (0 ms), NO-OUTDOOR, DFS, AUTO-BW
(5470 - 5725 @ 160), (N/A, 26), (0 ms), DFS
(5725 - 5875 @ 80), (N/A, 13), (N/A)
(57000 - 66000 @ 2160), (N/A, 40), (N/A)
phy#10 (self-managed)
country 00: DFS-UNSET
(2402 - 2437 @ 40), (6, 22), (N/A), AUTO-BW, NO-HT40MINUS, NO-80MHZ, NO-160MHZ
(2422 - 2462 @ 40), (6, 22), (N/A), AUTO-BW, NO-80MHZ, NO-160MHZ
(2447 - 2482 @ 40), (6, 22), (N/A), AUTO-BW, NO-HT40PLUS, NO-80MHZ, NO-160MHZ
(5170 - 5190 @ 160), (6, 22), (N/A), NO-OUTDOOR, AUTO-BW, IR-CONCURRENT, NO-HT40MINUS, PASSIVE-SCAN
(5190 - 5210 @ 160), (6, 22), (N/A), NO-OUTDOOR, AUTO-BW, IR-CONCURRENT, NO-HT40PLUS, PASSIVE-SCAN
(5210 - 5230 @ 160), (6, 22), (N/A), NO-OUTDOOR, AUTO-BW, IR-CONCURRENT, NO-HT40MINUS, PASSIVE-SCAN
(5230 - 5250 @ 160), (6, 22), (N/A), NO-OUTDOOR, AUTO-BW, IR-CONCURRENT, NO-HT40PLUS, PASSIVE-SCAN
(5250 - 5270 @ 160), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, PASSIVE-SCAN
(5270 - 5290 @ 160), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, PASSIVE-SCAN
(5290 - 5310 @ 160), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, PASSIVE-SCAN
(5310 - 5330 @ 160), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, PASSIVE-SCAN
(5490 - 5510 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, PASSIVE-SCAN
(5510 - 5530 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, PASSIVE-SCAN
(5530 - 5550 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, PASSIVE-SCAN
(5550 - 5570 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, PASSIVE-SCAN
(5570 - 5590 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, PASSIVE-SCAN
(5590 - 5610 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, PASSIVE-SCAN
(5610 - 5630 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, PASSIVE-SCAN
(5630 - 5650 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, PASSIVE-SCAN
(5650 - 5670 @ 80), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, NO-160MHZ, PASSIVE-SCAN
(5670 - 5690 @ 80), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, NO-160MHZ, PASSIVE-SCAN
(5690 - 5710 @ 80), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, NO-160MHZ, PASSIVE-SCAN
(5710 - 5730 @ 80), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, NO-160MHZ, PASSIVE-SCAN
(5735 - 5755 @ 80), (6, 22), (N/A), AUTO-BW, IR-CONCURRENT, NO-HT40MINUS, NO-160MHZ, PASSIVE-SCAN
(5755 - 5775 @ 80), (6, 22), (N/A), AUTO-BW, IR-CONCURRENT, NO-HT40PLUS, NO-160MHZ, PASSIVE-SCAN
(5775 - 5795 @ 80), (6, 22), (N/A), AUTO-BW, IR-CONCURRENT, NO-HT40MINUS, NO-160MHZ, PASSIVE-SCAN
(5795 - 5815 @ 80), (6, 22), (N/A), AUTO-BW, IR-CONCURRENT, NO-HT40PLUS, NO-160MHZ, PASSIVE-SCAN
(5815 - 5835 @ 20), (6, 22), (N/A), AUTO-BW, IR-CONCURRENT, NO-HT40MINUS, NO-HT40PLUS, NO-80MHZ, NO-160MHZ, PASSIVE-SCAN
To set the country value for the phy#10 interface, I trigger scanning with the following command:
$ sudo iw dev wlp3s0 scan
Then I verify the regulatory settings again to confirm that adapter determines it correctly:
$ sudo iw reg get
global
country FR: DFS-ETSI
(2400 - 2483 @ 40), (N/A, 20), (N/A)
(5150 - 5250 @ 80), (N/A, 23), (N/A), NO-OUTDOOR, AUTO-BW
(5250 - 5350 @ 80), (N/A, 20), (0 ms), NO-OUTDOOR, DFS, AUTO-BW
(5470 - 5725 @ 160), (N/A, 26), (0 ms), DFS
(5725 - 5875 @ 80), (N/A, 13), (N/A)
(57000 - 66000 @ 2160), (N/A, 40), (N/A)
phy#10 (self-managed)
country FR: DFS-UNSET
(2402 - 2437 @ 40), (6, 22), (N/A), AUTO-BW, NO-HT40MINUS, NO-80MHZ, NO-160MHZ
(2422 - 2462 @ 40), (6, 22), (N/A), AUTO-BW, NO-80MHZ, NO-160MHZ
(2447 - 2482 @ 40), (6, 22), (N/A), AUTO-BW, NO-HT40PLUS, NO-80MHZ, NO-160MHZ
(5170 - 5190 @ 160), (6, 22), (N/A), NO-OUTDOOR, AUTO-BW, IR-CONCURRENT, NO-HT40MINUS, PASSIVE-SCAN
(5190 - 5210 @ 160), (6, 22), (N/A), NO-OUTDOOR, AUTO-BW, IR-CONCURRENT, NO-HT40PLUS, PASSIVE-SCAN
(5210 - 5230 @ 160), (6, 22), (N/A), NO-OUTDOOR, AUTO-BW, IR-CONCURRENT, NO-HT40MINUS, PASSIVE-SCAN
(5230 - 5250 @ 160), (6, 22), (N/A), NO-OUTDOOR, AUTO-BW, IR-CONCURRENT, NO-HT40PLUS, PASSIVE-SCAN
(5250 - 5270 @ 160), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, PASSIVE-SCAN
(5270 - 5290 @ 160), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, PASSIVE-SCAN
(5290 - 5310 @ 160), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, PASSIVE-SCAN
(5310 - 5330 @ 160), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, PASSIVE-SCAN
(5490 - 5510 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, PASSIVE-SCAN
(5510 - 5530 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, PASSIVE-SCAN
(5530 - 5550 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, PASSIVE-SCAN
(5550 - 5570 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, PASSIVE-SCAN
(5570 - 5590 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, PASSIVE-SCAN
(5590 - 5610 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, PASSIVE-SCAN
(5610 - 5630 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, PASSIVE-SCAN
(5630 - 5650 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, PASSIVE-SCAN
(5650 - 5670 @ 80), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, NO-160MHZ, PASSIVE-SCAN
(5670 - 5690 @ 80), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, NO-160MHZ, PASSIVE-SCAN
(5690 - 5710 @ 80), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, NO-160MHZ, PASSIVE-SCAN
(5710 - 5730 @ 80), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, NO-160MHZ, PASSIVE-SCAN
(5735 - 5755 @ 80), (6, 22), (N/A), AUTO-BW, NO-HT40MINUS, NO-160MHZ
(5755 - 5775 @ 80), (6, 22), (N/A), AUTO-BW, NO-HT40PLUS, NO-160MHZ
(5775 - 5795 @ 80), (6, 22), (N/A), AUTO-BW, NO-HT40MINUS, NO-160MHZ
(5795 - 5815 @ 80), (6, 22), (N/A), AUTO-BW, NO-HT40PLUS, NO-160MHZ
(5815 - 5835 @ 20), (6, 22), (N/A), AUTO-BW, NO-HT40MINUS, NO-HT40PLUS, NO-80MHZ, NO-160MHZ
At this moment, iw list gives the following output (trunkated to minimize content):
Frequencies:
* 5180 MHz [36] (22.0 dBm) (no IR)
* 5200 MHz [40] (22.0 dBm) (no IR)
* 5220 MHz [44] (22.0 dBm) (no IR)
* 5240 MHz [48] (22.0 dBm) (no IR)
* 5260 MHz [52] (22.0 dBm) (no IR, radar detection)
* 5280 MHz [56] (22.0 dBm) (no IR, radar detection)
* 5300 MHz [60] (22.0 dBm) (no IR, radar detection)
* 5320 MHz [64] (22.0 dBm) (no IR, radar detection)
* 5340 MHz [68] (disabled)
* 5360 MHz [72] (disabled)
* 5380 MHz [76] (disabled)
* 5400 MHz [80] (disabled)
* 5420 MHz [84] (disabled)
* 5440 MHz [88] (disabled)
* 5460 MHz [92] (disabled)
* 5480 MHz [96] (disabled)
* 5500 MHz [100] (22.0 dBm) (no IR, radar detection)
* 5520 MHz [104] (22.0 dBm) (no IR, radar detection)
* 5540 MHz [108] (22.0 dBm) (no IR, radar detection)
* 5560 MHz [112] (22.0 dBm) (no IR, radar detection)
* 5580 MHz [116] (22.0 dBm) (no IR, radar detection)
* 5600 MHz [120] (22.0 dBm) (no IR, radar detection)
* 5620 MHz [124] (22.0 dBm) (no IR, radar detection)
* 5640 MHz [128] (22.0 dBm) (no IR, radar detection)
* 5660 MHz [132] (22.0 dBm) (no IR, radar detection)
* 5680 MHz [136] (22.0 dBm) (no IR, radar detection)
* 5700 MHz [140] (22.0 dBm) (no IR, radar detection)
* 5720 MHz [144] (22.0 dBm) (no IR, radar detection)
* 5745 MHz [149] (22.0 dBm)
* 5765 MHz [153] (22.0 dBm)
* 5785 MHz [157] (22.0 dBm)
* 5805 MHz [161] (22.0 dBm)
* 5825 MHz [165] (22.0 dBm)
* 5845 MHz [169] (disabled)
* 5865 MHz [173] (disabled)
* 5885 MHz [177] (disabled)
* 5905 MHz [181] (disabled)
With the following hostapd.conf:
ctrl_interface=/var/run/hostapd/
interface=wlan0 # overwritten with -i option
driver=nl80211
country_code=FR
ieee80211n=1
hw_mode=a
ieee80211ac=1
channel=149 # 5745 MHz
require_ht=1
require_vht=1
ieee80211d=1 # no impact on result with 0 as well
ieee80211h=1 # no impact on result with 0 as well
ssid=test-open
ieee80211w=2
auth_algs=1
wpa=0
I get the following output:
$ sudo hostapd /etc/hostapd/hostapd-5ghz-open.conf -i wlp3s0 -dd
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd-5ghz-open.conf
nl80211: TDLS supported
nl80211: TDLS external setup
nl80211: Supported cipher 00-0f-ac:1
nl80211: Supported cipher 00-0f-ac:5
nl80211: Supported cipher 00-0f-ac:2
nl80211: Supported cipher 00-0f-ac:4
nl80211: Supported cipher 00-0f-ac:8
nl80211: Supported cipher 00-0f-ac:9
nl80211: Supported cipher 00-0f-ac:6
nl80211: Supported cipher 00-0f-ac:11
nl80211: Supported cipher 00-0f-ac:12
nl80211: Using driver-based off-channel TX
nl80211: Driver-advertised extended capabilities (default) - hexdump(len=8): 04 00 00 00 00 00 00 40
nl80211: Driver-advertised extended capabilities mask (default) - hexdump(len=8): 04 00 00 00 00 00 00 40
nl80211: Driver-advertised extended capabilities for interface type STATION
nl80211: Extended capabilities - hexdump(len=10): 04 00 40 00 00 00 00 40 00 20
nl80211: Extended capabilities mask - hexdump(len=10): 04 00 40 00 00 00 00 40 00 20
nl80211: Use separate P2P group interface (driver advertised support)
nl80211: Enable multi-channel concurrent (driver advertised support)
nl80211: use P2P_DEVICE support
nl80211: key_mgmt=0x1ff0f enc=0x76f auth=0x7 flags=0x5800530fb5bfbe0 rrm_flags=0x79 probe_resp_offloads=0x0 max_stations=0 max_remain_on_chan=10000 max_scan_ssids=20
nl80211: interface wlp3s0 in phy phy10
nl80211: Set mode ifindex 14 iftype 3 (AP)
nl80211: Failed to set interface 14 to mode 3: -16 (Device or resource busy)
nl80211: Try mode change after setting interface down
nl80211: Set mode ifindex 14 iftype 3 (AP)
nl80211: Mode change succeeded while interface is down
nl80211: Setup AP(wlp3s0) - device_ap_sme=0 use_monitor=0
nl80211: Subscribe to mgmt frames with AP handle 0x55cefdc6f780
nl80211: Register frame type=0xb0 (WLAN_FC_STYPE_AUTH) nl_handle=0x55cefdc6f780 match= multicast=0
nl80211: Register frame type=0x0 (WLAN_FC_STYPE_ASSOC_REQ) nl_handle=0x55cefdc6f780 match= multicast=0
nl80211: Register frame type=0x20 (WLAN_FC_STYPE_REASSOC_REQ) nl_handle=0x55cefdc6f780 match= multicast=0
nl80211: Register frame type=0xa0 (WLAN_FC_STYPE_DISASSOC) nl_handle=0x55cefdc6f780 match= multicast=0
nl80211: Register frame type=0xc0 (WLAN_FC_STYPE_DEAUTH) nl_handle=0x55cefdc6f780 match= multicast=0
nl80211: Register frame type=0x40 (WLAN_FC_STYPE_PROBE_REQ) nl_handle=0x55cefdc6f780 match= multicast=0
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55cefdc6f780 match=04 multicast=0
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55cefdc6f780 match=0501 multicast=0
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55cefdc6f780 match=0503 multicast=0
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55cefdc6f780 match=0504 multicast=0
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55cefdc6f780 match=06 multicast=0
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55cefdc6f780 match=08 multicast=0
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55cefdc6f780 match=09 multicast=0
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55cefdc6f780 match=0a multicast=0
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55cefdc6f780 match=11 multicast=0
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x55cefdc6f780 match=7f multicast=0
rfkill: initial event: idx=10 type=1 op=0 soft=0 hard=0
nl80211: Add own interface ifindex 14 (ifidx_reason -1)
nl80211: if_indices[16]: 14(-1)
nl80211: Do not open EAPOL RX socket - using control port for RX
phy: phy10
BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
wlp3s0: interface state UNINITIALIZED->COUNTRY_UPDATE
Previous country code FR, new country code FR
nl80211: No channel number found for frequency 5905 MHz
nl80211: Regulatory information - country=00
nl80211: 2402-2437 @ 40 MHz 22 mBm
nl80211: 2422-2462 @ 40 MHz 22 mBm
nl80211: 2447-2482 @ 40 MHz 22 mBm
nl80211: 5170-5190 @ 160 MHz 22 mBm (no outdoor) (no IR)
nl80211: 5190-5210 @ 160 MHz 22 mBm (no outdoor) (no IR)
nl80211: 5210-5230 @ 160 MHz 22 mBm (no outdoor) (no IR)
nl80211: 5230-5250 @ 160 MHz 22 mBm (no outdoor) (no IR)
nl80211: 5250-5270 @ 160 MHz 22 mBm (DFS) (no IR)
nl80211: 5270-5290 @ 160 MHz 22 mBm (DFS) (no IR)
nl80211: 5290-5310 @ 160 MHz 22 mBm (DFS) (no IR)
nl80211: 5310-5330 @ 160 MHz 22 mBm (DFS) (no IR)
nl80211: 5490-5510 @ 240 MHz 22 mBm (DFS) (no IR)
nl80211: 5510-5530 @ 240 MHz 22 mBm (DFS) (no IR)
nl80211: 5530-5550 @ 240 MHz 22 mBm (DFS) (no IR)
nl80211: 5550-5570 @ 240 MHz 22 mBm (DFS) (no IR)
nl80211: 5570-5590 @ 240 MHz 22 mBm (DFS) (no IR)
nl80211: 5590-5610 @ 240 MHz 22 mBm (DFS) (no IR)
nl80211: 5610-5630 @ 240 MHz 22 mBm (DFS) (no IR)
nl80211: 5630-5650 @ 240 MHz 22 mBm (DFS) (no IR)
nl80211: 5650-5670 @ 80 MHz 22 mBm (DFS) (no IR)
nl80211: 5670-5690 @ 80 MHz 22 mBm (DFS) (no IR)
nl80211: 5690-5710 @ 80 MHz 22 mBm (DFS) (no IR)
nl80211: 5710-5730 @ 80 MHz 22 mBm (DFS) (no IR)
nl80211: 5735-5755 @ 80 MHz 22 mBm (no IR)
nl80211: 5755-5775 @ 80 MHz 22 mBm (no IR)
nl80211: 5775-5795 @ 80 MHz 22 mBm (no IR)
nl80211: 5795-5815 @ 80 MHz 22 mBm (no IR)
nl80211: 5815-5835 @ 20 MHz 22 mBm (no IR)
nl80211: Added 802.11b mode based on 802.11g information
nl80211: Mode IEEE 802.11g: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 2484[DISABLED]
nl80211: Mode IEEE 802.11a: 5180[NO_IR] 5200[NO_IR] 5220[NO_IR] 5240[NO_IR] 5260[NO_IR][RADAR] 5280[NO_IR][RADAR] 5300[NO_IR][RADAR] 5320[NO_IR][RADAR] 5340[DISABLED] 5360[DISABLED] 5380[DISABLED] 5400[DISABLED] 5420[DISABLED]
nl80211: Mode IEEE 802.11b: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 2484[DISABLED]
Allowed channel: mode=1 chan=1 freq=2412 MHz max_tx_power=22 dBm
Allowed channel: mode=1 chan=2 freq=2417 MHz max_tx_power=22 dBm
Allowed channel: mode=1 chan=3 freq=2422 MHz max_tx_power=22 dBm
Allowed channel: mode=1 chan=4 freq=2427 MHz max_tx_power=22 dBm
Allowed channel: mode=1 chan=5 freq=2432 MHz max_tx_power=22 dBm
Allowed channel: mode=1 chan=6 freq=2437 MHz max_tx_power=22 dBm
Allowed channel: mode=1 chan=7 freq=2442 MHz max_tx_power=22 dBm
Allowed channel: mode=1 chan=8 freq=2447 MHz max_tx_power=22 dBm
Allowed channel: mode=1 chan=9 freq=2452 MHz max_tx_power=22 dBm
Allowed channel: mode=1 chan=10 freq=2457 MHz max_tx_power=22 dBm
Allowed channel: mode=1 chan=11 freq=2462 MHz max_tx_power=22 dBm
Allowed channel: mode=1 chan=12 freq=2467 MHz max_tx_power=22 dBm
Allowed channel: mode=1 chan=13 freq=2472 MHz max_tx_power=22 dBm
Allowed channel: mode=0 chan=1 freq=2412 MHz max_tx_power=22 dBm
Allowed channel: mode=0 chan=2 freq=2417 MHz max_tx_power=22 dBm
Allowed channel: mode=0 chan=3 freq=2422 MHz max_tx_power=22 dBm
Allowed channel: mode=0 chan=4 freq=2427 MHz max_tx_power=22 dBm
Allowed channel: mode=0 chan=5 freq=2432 MHz max_tx_power=22 dBm
Allowed channel: mode=0 chan=6 freq=2437 MHz max_tx_power=22 dBm
Allowed channel: mode=0 chan=7 freq=2442 MHz max_tx_power=22 dBm
Allowed channel: mode=0 chan=8 freq=2447 MHz max_tx_power=22 dBm
Allowed channel: mode=0 chan=9 freq=2452 MHz max_tx_power=22 dBm
Allowed channel: mode=0 chan=10 freq=2457 MHz max_tx_power=22 dBm
Allowed channel: mode=0 chan=11 freq=2462 MHz max_tx_power=22 dBm
Allowed channel: mode=0 chan=12 freq=2467 MHz max_tx_power=22 dBm
Allowed channel: mode=0 chan=13 freq=2472 MHz max_tx_power=22 dBm
Frequency 5745 (primary) not allowed for AP mode, flags: 0x20053 NO-IR
Primary frequency not allowed
wlp3s0: IEEE 802.11 Configured channel (149) or frequency (5745) (secondary_channel=0) not found from the channel list of the current mode (2) IEEE 802.11a
wlp3s0: IEEE 802.11 Hardware does not support configured channel
Could not select hw_mode and channel. (-3)
wlp3s0: interface state COUNTRY_UPDATE->DISABLED
wlp3s0: AP-DISABLED
wlp3s0: Unable to setup interface.
hostapd_interface_deinit_free(0x55cefdc67e00)
hostapd_interface_deinit_free: num_bss=1 conf->num_bss=1
hostapd_interface_deinit(0x55cefdc67e00)
wlp3s0: interface state DISABLED->DISABLED
hostapd_bss_deinit: deinit bss wlp3s0
wlp3s0: Deauthenticate all stations
nl80211: send_mlme - da=ff:ff:ff:ff:ff:ff noack=0 freq=0 no_cck=0 offchanok=0 wait_time=0 no_encrypt=0 fc=0xc0 (WLAN_FC_STYPE_DEAUTH) nlmode=3
nl80211: send_mlme - Use bss->freq=0
nl80211: send_mlme -> send_frame_cmd
nl80211: CMD_FRAME freq=0 wait=0 no_cck=0 no_ack=0 offchanok=0
CMD_FRAME - hexdump(len=26): c0 00 00 00 ff ff ff ff ff ff 5c 80 b6 b8 dd af 5c 80 b6 b8 dd af 00 00 03 00
nl80211: Frame command failed: ret=-22 (Invalid argument) (freq=0 wait=0)
wlp3s0: AP-DISABLED
hostapd_cleanup(hapd=0x55cefdc68fe0 (wlp3s0))
wlp3s0: CTRL-EVENT-TERMINATING
hostapd_free_hapd_data: Interface wlp3s0 wasn't started
hostapd_interface_deinit_free: driver=0x55cefc144c60 drv_priv=0x55cefdc6a1f0 -> hapd_deinit
nl80211: deinit ifname=wlp3s0 disabled_11b_rates=0
nl80211: Remove monitor interface: refcount=0
nl80211: Remove beacon (ifindex=14)
netlink: Operstate: ifindex=14 linkmode=0 (kernel-control), operstate=6 (IF_OPER_UP)
nl80211: Set mode ifindex 14 iftype 2 (STATION)
nl80211: Failed to set interface 14 to mode 2: -16 (Device or resource busy)
nl80211: Try mode change after setting interface down
nl80211: Set mode ifindex 14 iftype 2 (STATION)
nl80211: Mode change succeeded while interface is down
nl80211: Teardown AP(wlp3s0) - device_ap_sme=0 use_monitor=0
nl80211: Unsubscribe mgmt frames handle 0x8888dd46754e7f09 (AP teardown)
hostapd_interface_free(0x55cefdc67e00)
hostapd_interface_free: free hapd 0x55cefdc68fe0
hostapd_cleanup_iface(0x55cefdc67e00)
hostapd_cleanup_iface_partial(0x55cefdc67e00)
hostapd_cleanup_iface: free iface=0x55cefdc67e00
The following lines from the above trigger my concern:
wlp3s0: interface state UNINITIALIZED->COUNTRY_UPDATE
Previous country code FR, new country code FR
nl80211: No channel number found for frequency 5905 MHz
nl80211: Regulatory information - country=00
Why does regulatory information is reset to the world domain provided that I set the correct country value? Is it caused by nl80211 driver, hostapd service, hardware or something else? I will appreciate any ideas which could provide me with some clarity on this subject.
|
To my surprise, the solution was installing the network-manager package. No additional configuration was required, not even setting the wireless interface as managed by NetworkManager. I replicated the same behaviour on another system (Raspberry Pi CM4 board with Ubuntu Server 20.04).
Just a note, Ubuntu Server comes with systemd-networkd as the default service for managing network, whereas Ubuntu Desktop comes with NetworkManager.
| Why can't hostapd service start AP configured in the 5 GHz band using Intel AX200 based adapter? |
1,444,231,093,000 |
I have a nice little iMX6 (an ARM CPU) board running Linux kernel 3.0.35 with hostapd 0.7.3. Setting up the wireless interface as an access point works fine but clients think they can be routed through it to the Internet. This would not be a problem except that I want to set up one client (my laptop) with its wired/Ethernet interface as lower priority than its wireless interface (which will connect to my AP). Right now when the laptop connects to the AP, its wireless interface takes precedence over its wired interface and all requests to Internet IPs fail (because the laptop is trying to route through the AP).
So I need to somehow set up the AP to "not advertise Internet access" so that clients don't attempt to reach Internet IP addresses through it. This is a hard thing to search for.
My AP configuration:
dhcpd.conf:
ddns-update-style none;
default-lease-time 86400;
max-lease-time 604800;
authoritative;
subnet 10.11.12.0 netmask 255.255.255.0 {
range 10.11.12.14 10.11.12.99;
option subnet-mask 255.255.255.0;
option broadcast-address 10.11.12.255;
option routers 10.11.12.13;
}
hostapd.conf:
interface=wlan0
ssid=Cameras
hw_mode=g
channel=6
/etc/network/interfaces:
auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet static
address 10.11.12.13
netmask 255.255.255.0
network 10.11.12.0
|
Your problem is so obvious that you're going to knock yourself on the head once you see it: stop advertising a router -- get rid of your "option routers" line in your dhcpd.conf. If you do have a subnet behind your AP, you can have dhcpd push static routes with "option static-routes", IIRC. But you don't need a router pushed by dhcpd because your client and the AP both reside on the same subnet: no layer three routing is involved at all. And so, once you stop stepping on your system's already-established default gateway, everything should "just work."
| How do I prevent my hostapd access point from pretending to route to the Internet? |
1,444,231,093,000 |
In the documentation of Debian it is written that:
Just like you can bridge two wired ethernet interfaces, you can bridge between an ethernet interface and a wireless interface. However, most Access Points (APs) will reject frames that have a source address that didn’t authenticate with the AP. Since Linux does ethernet bridging transparently (doesn’t modify outgoing or incoming frames), we have to set up some rules to do this with a program called ebtables.
I wonder why a machine connected to the wired Ethernet interface can not authenticate with the AP. In such case, the bridge should work normally, shouldn't it?
|
The problem is that wireless frames in the regular mode only have space for three MAC addresses. The details are a bit more complex, but roughly speaking, there's one MAC address for the external interface of the "distribution system", as it is called in the standard (the collection of access points), one for the access point itself, and one for the station (client).
This is why you can bridge an access point, but not a station: There is no MAC address left for any other machine behind the station bridge. The MAC address of the station could be replaced by this address, but then the AP will reject it, as described in your quote, because this packet looks like it comes from another station that's not associated (and doesn't have encryption established, if you are using WPA).
Now there is a newer 4-address-mode (sometimes also called WDS = wire distribution system; sometimes WDS means a proprietary extensions), but you have to change all your WLAN devices to 4-address-mode for this to work.
Another option is to allow multiple stations on a single network interface - newer WLAN cards allow this, and then you could in principle use on of these as a proxy for the bridged machine (but it requires extra effort; simple bridging still won't do, because you have to hide the MAC address of the station).
| Why can't we easily bridge over a wireless NIC |
1,444,231,093,000 |
I have ubuntu 14.04 installed on a computer with a built-in wifi and also a usb wifi. I want to run hostapd on built-in wifi to act as an access point though no connection will be established with it. I only need it to read signal levels from another device.
when I enter the following on terminal I am able to see the built-in wifi as an access point;
sudo nmcli nm wifi off
sudo rfkill unblock wlan
sudo service hostapd start
but since this turns off all the wireless connection, my internet connection with the usb dongle also is lost. I am able to enable it back with
sudo nmcli nm wifi on
but then the built-in wifi stops acting as an access point(not visible to other wireless devices anymore) even though iwconfig still shows the interface in master mode.
Is what i am trying to achieve impossible? 2 wireless interfaces, one in managed mode connected to internet and another one in master mode acting as an access point?
|
After the commands above, restarting the hostapd did the trick.
sudo service hostapd restart
Now the internal wifi works as an access point and the usb dongle is connected to another access point providing internet connection.
| "nmcli nm wifi on" stops hostapd |
1,444,231,093,000 |
I'm trying to set up my Raspberry Pi Compute Module 3+ as an access point with an access point with a WiFi dongle.
I'm following this tutorial : https://elinux.org/RPI-Wireless-Hotspot.
I can set up the access point with the dongle EP-N8508GS, but when I try with the TL-WN722N, I have this error:
pi@raspberrypi:~ $ sudo service hostapd start
Job for hostapd.service failed because the control process exited with error code.
See "systemctl status hostapd.service" and "journalctl -xe" for details.
It seems to be a problem with the nl80211 driver but I don't really understand why it works with the first dongle but not with the other one. I want to try with the tp-link dongle because the first one doesn't support AP-mode and crash the kernell when a device try to connect.
$ service hostapd status
pi@raspberrypi:~ $ service hostapd status
● hostapd.service - Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator
Loaded: loaded (/lib/systemd/system/hostapd.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Mon 2019-05-06 03:49:27 BST; 1
Process: 1103 ExecStart=/usr/sbin/hostapd -P /run/hostapd.pid -B $DAEMON_OPTS ${DAEMON_CONF
May 06 03:49:27 raspberrypi systemd[1]: hostapd.service: Control process exited, code=exited
May 06 03:49:27 raspberrypi systemd[1]: Failed to start Advanced IEEE 802.11 AP and IEEE 802.
May 06 03:49:27 raspberrypi systemd[1]: hostapd.service: Unit entered failed state.
May 06 03:49:27 raspberrypi systemd[1]: hostapd.service: Failed with result 'exit-code'.
$ journalctl -xe
pi@raspberrypi:~ $ journalctl -xe
May 06 04:10:22 raspberrypi hostapd[619]: nl80211: Driver does not support authentication/ass
May 06 04:10:22 raspberrypi hostapd[619]: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
May 06 04:10:22 raspberrypi hostapd[619]: nl80211 driver initialization failed.
May 06 04:10:22 raspberrypi hostapd[619]: wlan0: interface state UNINITIALIZED->DISABLED
May 06 04:10:22 raspberrypi hostapd[619]: wlan0: AP-DISABLED
May 06 04:10:22 raspberrypi hostapd[619]: hostapd_free_hapd_data: Interface wlan0 wasn't star
May 06 04:10:22 raspberrypi systemd[1]: hostapd.service: Control process exited, code=exited
May 06 04:10:22 raspberrypi systemd[1]: Failed to start Advanced IEEE 802.11 AP and IEEE 802.
-- Subject: Unit hostapd.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit hostapd.service has failed.
--
-- The result is failed.
May 06 04:10:22 raspberrypi systemd[1]: hostapd.service: Unit entered failed state.
May 06 04:10:22 raspberrypi systemd[1]: hostapd.service: Failed with result 'exit-code'.
May 06 04:10:25 raspberrypi systemd[1]: hostapd.service: Service hold-off time over, scheduli
May 06 04:10:25 raspberrypi systemd[1]: Stopped Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/W
-- Subject: Unit hostapd.service has finished shutting down
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit hostapd.service has finished shutting down.
May 06 04:10:25 raspberrypi systemd[1]: Starting Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/
-- Subject: Unit hostapd.service has begun start-up
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit hostapd.service has begun starting up.
May 06 04:10:25 raspberrypi hostapd[621]: Configuration file: /etc/hostapd/hostapd.conf
May 06 04:10:25 raspberrypi hostapd[621]: nl80211: Driver does not support authentication/ass
May 06 04:10:25 raspberrypi hostapd[621]: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
May 06 04:10:25 raspberrypi hostapd[621]: nl80211 driver initialization failed.
May 06 04:10:25 raspberrypi hostapd[621]: wlan0: interface state UNINITIALIZED->DISABLED
May 06 04:10:25 raspberrypi hostapd[621]: wlan0: AP-DISABLED
May 06 04:10:25 raspberrypi hostapd[621]: hostapd_free_hapd_data: Interface wlan0 wasn't star
May 06 04:10:25 raspberrypi systemd[1]: hostapd.service: Control process exited, code=exited
May 06 04:10:25 raspberrypi systemd[1]: Failed to start Advanced IEEE 802.11 AP and IEEE 802.
-- Subject: Unit hostapd.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit hostapd.service has failed.
--
-- The result is failed.
May 06 04:10:25 raspberrypi systemd[1]: hostapd.service: Unit entered failed state.
May 06 04:10:25 raspberrypi systemd[1]: hostapd.service: Failed with result 'exit-code'.
And my config :
/lib/systemd/system/hostapd.service
pi@raspberrypi:~ $ cat /lib/systemd/system/hostapd.service
[Unit]
Description=Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator
After=network.target
[Service]
Type=forking
PIDFile=/run/hostapd.pid
Restart=on-failure
RestartSec=2
EnvironmentFile=/etc/default/hostapd
ExecStart=/usr/sbin/hostapd -P /run/hostapd.pid -B $DAEMON_OPTS ${DAEMON_CONF}
/etc/default/hostapd
pi@raspberrypi:~ $ cat /etc/default/hostapd
# Defaults for hostapd initscript
#
# See /usr/share/doc/hostapd/README.Debian for information about alternative
# methods of managing hostapd.
#
# Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration
# file and hostapd will be started during system boot. An example configuration
# file can be found at /usr/share/doc/hostapd/examples/hostapd.conf.gz
#
DAEMON_CONF="/etc/hostapd/hostapd.conf"
# Additional daemon options to be appended to hostapd command:-
# -d show more debug messages (-dd for even more)
# -K include key data in debug messages
# -t include timestamps in some debug messages
#
# Note that -B (daemon mode) and -P (pidfile) options are automatically
# configured by the init.d script and must not be added to DAEMON_OPTS.
#
#DAEMON_OPTS=""
/etc/hostapd/hostapd.conf
pi@raspberrypi:~ $ cat /etc/hostapd/hostapd.conf
interface=wlan0
ssid=MyAP
hw_mode=g
channel=1
auth_algs=1
ieee80211n=1 # 802.11n support
wmm_enabled=1 # QoS support
ht_capab=[HT40+][SHORT-GI-20][DSSS_CCK-40]
|
It seems that you need a driver for tp-link USB dongle soft-AP. I resolve this problem by installing this driver. You can find it : here
| Hostapd doesn't work for one of my device |
1,444,231,093,000 |
Let me refer responders to this thread on Linux Mint forums:
Chrome/Firefox not loading Google websites
I've seen this four times in the past two weeks or so. The loss of connection does eventually clear after an unknown time (longest has been 4 days).
In a nut shell, almost all URL-s work but key ones you'd need to do (actual) stuff like google.com, linkedin.com, youtube.com or yahoo.com, etc. fail. While other sites you'd think are related work. It is unpredictable. Tonight is a good example. URL:
http://mail.google.com - fails, while
http://google.com (search) - displays.
The issue affects everything I've tested (for the 'missing' url)...
firefox
chrome
curl
wget
dig
I don't know if it is specifically the DNS.
(update: 2015-11-11)
The fortunate experience swapping to and back from a mobile broadband modem was not a 'workaround' just a lucky-break. Results from such a swap don't always work.
I think the DNS issue(s) are just a symptom. The message for
curl https//:mail.google.com
Gives back is...
curl: (7) Couldn't connect to server
Which I'm guessing means it can "see" the server but won't connect. As mentioned I can send email from other things using the same access point e.g. Android phone so wondering what diagnostics there are for this kind of thing in Linux Mint so I can get a handle on what part of the stack is getting stuck?
(update: 2015-11-10)
I have some new information. It may help others, or give the brain's trust a tip on how to resolve this problem. This evening I was unable to access GitHub, stackexchange.com, netbeans, and Wikipedia, to name a few. I am here now, so what happened?
When I pressed F5 here, I received this banner message at the top of the screen:
Unix & Linux Stack Exchange requires external
JavaScript from another domain, which is blocked
or failed to load.
woops I thought, it has happened again. I really wanted to check for any responses, because as you can imagine this error is retarding significant progress -- So I have a little credit on a USB modem. I thought I'd try to use that.
Swapped-out the WI-FI access point
Connected to the USB/mobile network
Result: No change, can't get wikipedia and the annoying script message thing was showing on this page.
Disconnect from the USB/Mobile broadband network
Reconnect he Wi-Fi access point
One of my Dig tests gave a different result After connecting (back) to the Wi-Fi access point. So (now) ...
The annoying banner message on StackExchange is gone. I can see wikipedia and github again.
It appears that something in the stack doesn't get reset/refreshed until the 'Wired' (access point) connection is reconnected. But not just reconnected; being usurped so that it has to reconnect everything (again).
The other odd thing; is that the mobile broadband did NOT refresh/reset the (effective) stuff on the data comm. stack. Why not? How?
More importantly what may I do to force the reset/refresh on the Wired connection and the Wi-Fi connection without renewing a defunct mobile broadband when the current merger residual credits drip away??!!
Otherwise things remain the same as they were for the last update
(update end)
At the moment all I can say is that google search (working) and gmail (not working) demonstrate the following responses from dig.
$ dig google.com
; <<>> DiG 9.9.5-3ubuntu0.5-Ubuntu <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19398
;; flags: qr rd ra; QUERY: 1, ANSWER: 15, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;google.com. IN A
;; ANSWER SECTION:
google.com. 114 IN A 120.19.255.38
google.com. 114 IN A 120.19.255.27
google.com. 114 IN A 120.19.255.19
google.com. 114 IN A 120.19.255.59
google.com. 114 IN A 120.19.255.53
google.com. 114 IN A 120.19.255.29
google.com. 114 IN A 120.19.255.15
google.com. 114 IN A 120.19.255.49
google.com. 114 IN A 120.19.255.57
google.com. 114 IN A 120.19.255.34
google.com. 114 IN A 120.19.255.23
google.com. 114 IN A 120.19.255.45
google.com. 114 IN A 120.19.255.44
google.com. 114 IN A 120.19.255.42
google.com. 114 IN A 120.19.255.30
;; Query time: 108 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Tue Nov 03 23:14:22 AEDT 2015
;; MSG SIZE rcvd: 268
and $ dig mail.google.com
; <<>> DiG 9.9.5-3ubuntu0.5-Ubuntu <<>> mail.google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40641
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;mail.google.com. IN A
;; AUTHORITY SECTION:
. 49606 IN NS localhost.
;; Query time: 106 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Tue Nov 03 23:15:02 AEDT 2015
;; MSG SIZE rcvd: 55
In contrast the dig output on a working box I have access to shows a different story as far as nameservers go.
On a working machine: $ dig gmail.com (added in update)
; <<>> DiG 9.6-ESV-R11 <<>> gmail.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22330
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;gmail.com. IN A
;; ANSWER SECTION:
gmail.com. 192 IN A 216.58.220.101
;; Query time: 15 msec
;; SERVER: 192.168.172.1#53(192.168.172.1)
;; WHEN: Wed Nov 04 14:02:50 EST 2015
;; MSG SIZE rcvd: 43
In the first non-working example, the Linux set-up is using localhost. To me, that sounds like I need it to do a refresh or something. Comments?
Nitty gritty detail, is:
Linux Mint v17.2 - Rafaela (Cinnamon 64-bit)
dnsmasq version 2.68
I tested the network restart suggested on the forum, alas it didn't assist me accessing gmail. Back to the drawing boars/stackexchange :-)
Apart from the question on the Mint forum I haven't found anything to indicate 'yea' or 'nay' for this problem. The first post on this issue was way back in 2011 and it looks like it was skipped as a 'non-good' question so this phenomena has been about for a while. It would be good to find an effective response. Hopefully one of us has a fix already.
Suggestions welcome and happy to look-up further information.
|
(update: 2015-12-16)
These last few days I had occasion to use-up the remaining MB-s on the USB modem. I have had exactly zero DNS issues.
At one point I lent the USB wireless broadband modem to someone; and used the micro-USB via a mobile phone (same network provider). DNS issues returned in very short shrift!
The workaround seems to be avoid micro-USB wired connections (mobile phones). Or connect via wi-fi.
I may have a path forward, if not an actual solution. For this problem I need to see how it plays out over a say a month and ensure there's no outages.
This system has a new install of Linux Mint 17.2 - Rafaela. I haven't knowingly touched the network set-up prior to having troubles. It more or less worked fine initially. As this was an intermittent problem I can't say.
Looking at the Mint page, I found this system was missing the
/etc/dnsmasq.conf config file
So I decided to (re-)install dnsmasq
sudo apt-get install dnsmasq
And work through the tutorial as well as referring to the subsection on using Google DNS wiki page. And restarted dnsmasq.
sudo /etc/init.d/dnsmasq restart
In any case, sometimes the best thing is to reinstall and ensure you have a clean slate. Tests so far show things working fine. The DNS cache definitely was NOT working before I reinstalled. My dig time is now close to zero on common domains! yea
Hope that helps other. Btw I saw lots of information about putting back NetworkManager. As I understand that, NetworkManager is an Alternate to a DNSmasq set-up. I welcome clarification on that part. In a any case the two are not compatible together as far as I know.
At present DNSmasq is better for me. It, it has been in Debian -> Ubuntu -> Mint for some time so it's a fair comment to say it's the better option most of the time.
some resources:
Local DNS Cache for Faster Internet Browsing on your Linux Mint
dnsmasq (ubuntu)
howto dnsmasq (debian)
Prevent OpenDNS Redirecting_Google Queries
| How can I (re-)connect DNS for gmail on Linux Mint? |
1,444,231,093,000 |
I am setting up a local survey system. The linux laptop will run limesurvey (on a typical LAMP stack) and will be accessible by 5 tablets given out to conference participants. Tablets are no problem as they would be pre-configured with survey loaded. I would like however to allow the conference participants to access the survey link from their mobile phones too. What I would plan to do is this:
Laptop serves as access point. DNSMASQ gives out IPs after they join the AP. I would give them a simple local address (e.g. http://lime) to access the survey interface and this should be possible because DNSMASQ will function as their DNS server - so it will know how to resolve lime.
I would like to deal with client errors swiftly - e.g. they, after joining the AP, type in a different address by accident (or just want to go on internet e.g. to google.com) - I would like DNSMASQ to immediately return an error, preferably with a redirect to a custom error page giving them the correct link.
Edit: I looked into this; likely I will have to make a captive portal type solution. I still would like the simplest possible way to display the splash page - with survey(s) listed and drop/redirect all other requests to the splash page. I do not need authentication as no internet is going to be offered through this connection; authentication would be just extra clicks in this case but I want people to have access to the survey with no hassle.
Would this be possible? Would there be better ways how to execute this plan?
|
Sure! Redirect all name resolutions to one address with the command:
address=/#/10.0.0.101
That is the entry required in the /etc/dnsmasq.conf file. Which I recommend using as that will enforce such configuration if the server is reboot for any reason.
On the command line, the option is called:
-A, --address=/<domain>[/<domain>...]/[<ipaddr>]
A copy of the dnsmasq manual for address= is below.
However, even if it may seem reasonable to set -i vlan (to the expected interface to be used) and -a 10.6.66.1 (to the address in which it is expected that dnsmasq will listen for DNS resolution). Do not do that!.
Allow dnsmasq to bind in wildcard mode to any and all the server addresses on port 53. That way any request to the server about DNS resolution will be answered by dnsmasq.
The three modes are "wildcard", "bind-interfaces" and "bind-dynamic".
In "wildcard" mode, dnsmasq binds the wildcard IP address (0.0.0.0 or
::). This allows it to receive all the packets sent to the server on
the relevant port. Access control (--interface, --except-interface,
--listen-address, etc) is implemented by dnsmasq: it queries the
kernel to determine the interface on which a packet was received and
the address to which it was sent, and applies the configured
rules. Wildcard mode is the default if neither of the other modes are
specified.
Use port 53 (as external clients will expect that by default):
port=53 # It is set to be 53 by default, not really needed.
Turn off (and disallow) both avahi-dns and systemd.resolved
Make sure that no other program/service is listening on ports 53 or 5353.
$ netstat -pantu | grep ':53'
Also set this options to enforce that names like mylocaldomain (no dots) are resolved with an error (NXDOMAIN) by the dnsmasq DNS resolver and that (some) name resolutions are not forwarded to any other server:
# Never forward plain names (without a dot or domain part)
domain-needed
# Never forward addresses in the non-routed address spaces.
bogus-priv
Ensure that any server set in /etc/resolv.conf is not used:
no-resolv
no-poll
All the above will configure the DNS side of dnsmasq to resolve all domains to one simple address. It is still possible to add any other name to resolve other needed addresses by including it in the /etc/hosts file, like
127.0.0.1
10.0.3.101 linum
This last address should be the address to the web-server for the survey.
The initial address above (10.0.0.101) should be the error page that explain what to do to access the survey page.
But that is not all. You also need to configure the DHCP server to supply a nameserver option with the address of the dnsmasq DNS resolver (d not use option number 5, it is obsolete (and should have been for more than 20 years)):
dhcp-option=6,10.0.0.101
Plus all the other needed configurations for the DHCP part of dnsmasq.
That will allow a computer (tablet or phone also) to get a DHCP given address with a defined DNS server. All protocol compliant computers will follow such configured options and be unable to resolve any other address.
However, it is also possible that a device may try to access directly a IP number (no DNS resolution requested). That must be avoided using IPFilter configuration on the router that serve the local network.
From man dnsmasq:
-A, --address=/[/...]/[]
Specify an IP address to return for any host in the given domains. Queries in the domains are never forwarded and always replied to with the specified IP address which may be IPv4 or IPv6. To give both IPv4 and IPv6 addresses for a domain, use repeated -A flags. To include multiple IP addresses for a single query, use --addn- hosts= instead. Note that /etc/hosts and DHCP leases override this for individual names. A common use of this is to redirect the entire doubleclick.net domain to some friendly local web server to avoid banner ads. The domain specification works in the same was as for --server, with the additional facility that /#/ matches any domain. Thus --address=/#/1.2.3.4 will always return 1.2.3.4 for any query not answered from /etc/hosts or DHCP and not sent to an upstream nameserver by a more specific --server directive. As for --server, one or more domains with no address returns a no-such-domain answer, so --address=/example.com/ is equivalent to --server=/example.com/ and returns NXDOMAIN for example.com and all its subdomains.
Also read:
Add forged DNS entries
Bind configuration to resolve all queries to only one address
| Can I get dnsmasq to drop/reject/redirect any address queries except one? |
1,444,231,093,000 |
I'm looking for a simple way to configure an external Access Point (IP address, SSID, WPA key, turn WiFi on/off, etc.) via Linux command line instead of the standard web interface that APs offer.
This could be either an off-the-shelf AP that offers this feature, or a procedure to accomplish this with any standard APs. I realize the question might seem too broad; I'd like to find the simplest solution for this.
|
You'll (almost certainly) need to flash a custom firmware on the AP to enable this functionality. The two most common firmwares to use for this are OpenWRT and DD-WRT. They're very similar but have slightly different hardware compatibility lists. If you already have the AP check to see if one of them support it. If you're looking to buy an AP check it's compatibility with one of them before you buy. I've done extensive work with DD-WRT on a Linksys WRT54GL and it works like a charm. Best wifi router ever made IMHO.
| Access Point configurable via Linux [duplicate] |
1,444,231,093,000 |
I would like to switch which AP an iot device is connected to based on some external logic. My AP switching script looked like this:
function switch_ap() {
current_connection=$(nmcli conn show --active | tail -n 1 | cut -d' ' -f1)
nmcli conn down $current_connection
if test "$current_connection" = "home_ap"; then
nmcli conn up iot_ap
else
nmcli conn up home_ap
fi
new_connection=$(nmcli conn show --active | tail -n 1 | cut -d' ' -f1)
echo "was connected to $current_connection, now connected to connection: $(nmcli conn show --active | tail -n 1 | cut -d' ' -f1) ssid: $(iwgetid wlan0 -r)"
}
Sometimes this works, but not reliably. More often I get an error:
Connection 'home_ap' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/66)
Error: Connection activation failed: The base network connection was interrupted
Hint: use 'journalctl -xe NM_CONNECTION=dcbf7f18-1e26-41bb-a874-c1ce6718dbf2 + NM_DEVICE=wlan0' to get more details.
I don't see the problem from running the journalctl command, but I'll share the output at the bottom of this post in case someone else is better at parsing those logs.
My hack-fix is this function:
function switch_ap() {
current_connection=$(nmcli conn show --active | tail -n 1 | cut -d' ' -f1)
nmcli conn down $current_connection
if test "$current_connection" = "home_ap"; then
mv /etc/nm_connections/iot_ap.nmconnection /opt/nm_connections/
mv /opt/home_ap.nmconnection /etc/nm_connections/
nmcli conn up iot_ap
else
mv /etc/nm_connections/home_ap.nmconnection /opt/nm_connections/
mv /opt/nm_connections/iot_ap.nmconnection /etc/nm_connections/
nmcli conn up home_ap
fi
new_connection=$(nmcli conn show --active | tail -n 1 | cut -d' ' -f1)
echo "was connected to $current_connection, now connected to connection: $(nmcli conn show --active | tail -n 1 | cut -d' ' -f1) ssid: $(iwgetid wlan0 -r)"
}
This one seems to work reliably, but now I won't automatically switch if I lose connection to the connected ap, and it is a hack. I now also see these warnings more frequently:
(process:12734): GLib-GIO-WARNING **: 06:05:20.284: ../../gio/gdbusobjectmanagerclient.c:1589: Processing InterfaceRemoved signal for path /org/freedesktop/NetworkManager/IP4Config/35 but no object proxy exists
(process:12734): GLib-GIO-WARNING **: 06:05:20.293: ../../gio/gdbusobjectmanagerclient.c:1589: Processing InterfaceRemoved signal for path /org/freedesktop/NetworkManager/IP6Config/35 but no object proxy exists
(process:12734): GLib-GIO-WARNING **: 06:05:20.591: ../../gio/gdbusobjectmanagerclient.c:1589: Processing InterfaceRemoved signal for path /org/freedesktop/NetworkManager/ActiveConnection/35 but no object proxy exists
Any ideas to make my AP switching more reliable?
Here are the logs from the journalctl command:
Connection 'iot_ap' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/33)
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/37)
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info> [1587481388.5536] device (wlan0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info> [1587481388.5912] device (wlan0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info> [1587481388.5946] device (wlan0): Activation: (wifi) access point 'home_ap' has security, but secrets are required.
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info> [1587481388.5948] device (wlan0): state change: config -> need-auth (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info> [1587481388.6554] device (wlan0): state change: need-auth -> prepare (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info> [1587481388.6598] device (wlan0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info> [1587481388.6634] device (wlan0): Activation: (wifi) connection 'home_ap' has security, and secrets exist. No new secrets needed.
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info> [1587481388.9623] device (wlan0): disconnecting for new activation request.
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info> [1587481388.9626] device (wlan0): state change: config -> deactivating (reason 'new-activation', sys-iface-state: 'managed')
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info> [1587481388.9781] device (wlan0): state change: deactivating -> disconnected (reason 'new-activation', sys-iface-state: 'managed')
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info> [1587481389.0102] device (wlan0): Activation: starting connection 'iot_ap' (b109024a-84b9-46b7-a810-2d2472676c7f)
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info> [1587481389.0413] device (wlan0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info> [1587481389.0750] device (wlan0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info> [1587481389.0810] device (wlan0): Activation: (wifi) access point 'iot_ap' has security, but secrets are required.
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info> [1587481389.0819] device (wlan0): state change: config -> need-auth (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info> [1587481389.0867] sup-iface[0x3a2201c0,wlan0]: wps: type pbc start...
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info> [1587481389.8388] device (wlan0): state change: need-auth -> prepare (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info> [1587481389.8922] device (wlan0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info> [1587481389.9060] device (wlan0): Activation: (wifi) connection 'iot_ap' has security, and secrets exist. No new secrets needed.
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info> [1587481389.9470] device (wlan0): supplicant interface state: disconnected -> inactive
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info> [1587481390.4927] device (wlan0): supplicant interface state: inactive -> associating
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info> [1587481390.5582] device (wlan0): disconnecting for new activation request.
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info> [1587481390.5584] device (wlan0): state change: config -> deactivating (reason 'new-activation', sys-iface-state: 'managed')
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info> [1587481390.5645] device (wlan0): state change: deactivating -> disconnected (reason 'new-activation', sys-iface-state: 'managed')
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info> [1587481390.5915] device (wlan0): Activation: starting connection 'home_ap' (dcbf7f18-1e26-41bb-a874-c1ce6718dbf2)
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info> [1587481390.6027] device (wlan0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info> [1587481390.6214] device (wlan0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info> [1587481390.6386] device (wlan0): Activation: (wifi) access point 'home_ap' has security, but secrets are required.
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info> [1587481390.6388] device (wlan0): state change: config -> need-auth (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <warn> [1587481390.6968] sup-iface[0x3a2201c0,wlan0]: connection disconnected (reason -3)
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info> [1587481390.6974] device (wlan0): supplicant interface state: associating -> disconnected
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info> [1587481390.6983] device (wlan0): state change: need-auth -> prepare (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info> [1587481390.7046] device (wlan0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info> [1587481390.7357] device (wlan0): Activation: (wifi) connection 'home_ap' has security, and secrets exist. No new secrets needed.
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info> [1587481390.7815] device (wlan0): supplicant interface state: disconnected -> associated
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <warn> [1587481390.7900] sup-iface[0x3a2201c0,wlan0]: connection disconnected (reason -3)
Apr 21 09:03:11 DEVICE-072059 NetworkManager[249]: <info> [1587481391.0013] device (wlan0): supplicant interface state: associated -> disconnected
Apr 21 09:03:11 DEVICE-072059 NetworkManager[249]: <info> [1587481391.6999] device (wlan0): supplicant interface state: disconnected -> associating
Apr 21 09:03:11 DEVICE-072059 NetworkManager[249]: <info> [1587481391.7886] device (wlan0): supplicant interface state: associating -> 4-way handshake
Apr 21 09:03:11 DEVICE-072059 NetworkManager[249]: <info> [1587481391.8417] device (wlan0): supplicant interface state: 4-way handshake -> completed
Apr 21 09:03:11 DEVICE-072059 NetworkManager[249]: <info> [1587481391.8419] device (wlan0): Activation: (wifi) Stage 2 of 5 (Device Configure) successful. Connected to wireless network "TheHome"
Apr 21 09:03:11 DEVICE-072059 NetworkManager[249]: <info> [1587481391.8624] device (wlan0): state change: config -> ip-config (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:11 DEVICE-072059 NetworkManager[249]: <info> [1587481391.8689] dhcp4 (wlan0): activation: beginning transaction (timeout in 45 seconds)
Apr 21 09:03:11 DEVICE-072059 NetworkManager[249]: <info> [1587481391.8964] dhcp4 (wlan0): dhclient started with pid 22677
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info> [1587481392.2540] dhcp4 (wlan0): address 192.168.1.61
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info> [1587481392.2542] dhcp4 (wlan0): plen 24 (255.255.255.0)
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info> [1587481392.2543] dhcp4 (wlan0): gateway 192.168.1.1
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info> [1587481392.2546] dhcp4 (wlan0): lease time 10806
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info> [1587481392.2547] dhcp4 (wlan0): nameserver '75.75.75.75'
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info> [1587481392.2548] dhcp4 (wlan0): nameserver '75.75.76.76'
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info> [1587481392.2550] dhcp4 (wlan0): state changed unknown -> bound
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info> [1587481392.2964] device (wlan0): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info> [1587481392.3029] device (wlan0): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info> [1587481392.3051] device (wlan0): state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info> [1587481392.4438] device (wlan0): Activation: successful, device activated.
|
Network manager is made to mange networks, it has logic to switch networks based on availability. when you run the first script and take it down, the network manager daemon probably notices and connects to whatever is the default that’s available.
The second one you’re moving the files that tell network manager which wifi access points it should connect to. So when it has the home file it’ll only ever be able to connect to home because that’s the only network it knows about. When it has the iot file it’ll only be able to connect to iot.
It won’t switch because network manager doesn’t know the other exists. The best way to fix your issue would be to set the priority for the SSIDs in network manager or to use “nmcli device wifi connect ” which should work to connect to a different SSID without taking it down. If not that command the nmcli man pages should be useful figuring out how.
| NetworkManager is failing to switch AP: Connection Activation Failed |
1,444,231,093,000 |
I'm trying to setup a raspberrypi 4 as a wifi access point. Following the official documentation I managed to bridge my eth0 interface and setup hostapd. The bridges IP is provided by an exisiting DHCP server on the network in contrast to the documentation.
The problem I'm facing is that none of the connected wifi devices are getting an IPv4 address. They are capable of connecting to the internet by IPv6 though but then fail to connect to any IPv4 target on the internet.
Browsing IPv6 based websites works fine from any wifi client (Android or Windows 10).
Linux raspberrypi4 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux
hostapd v2.8-devel
|
A.B's comment is actually right. My raspi and the current raspbian on it do load the br_netfilter module. Upon removing it and after restarting hostapd all my clients do now get valid IPv4 adresses. Inserting the module breaks the functionality again.
Thank you A.B!
| hostapd clients don't get ipv4 addresses |
1,444,231,093,000 |
Background: I am trying to set up an access point on Linux. The ultimate aim is to run SSLStrip (for an exercise) so I need to be able to do something like this, to redirect port 80 traffic through port 10000, on which SSLStrip listens.
iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 10000
Using Linux - Kali2, 64bit. Machine has internet access via eth0.
This is how I am setting up the access point:
airmon-ng start wlan0 6
modprobe tun
ifconfig wlan0mon down
iwconfig wlan0mon mode monitor
ifconfig wlan0mon up
airbase-ng -e "MyAccessPoint" -c 6 wlan0mon &
ifconfig "at0" up
ifconfig "at0" "10.0.0.1" netmask "255.255.255.0"
ifconfig "at0" mtu 1500
route add -net "10.0.0.0" netmask "255.255.255.0" gw "10.0.0.1" dev "at0"
Into /etc/dhcp/dhcpd.conf I put the following:
subnet 10.0.0.0 netmask 255.255.255.0 {
authoritative;
range 10.0.0.100 10.0.0.200;
default-lease-time 3600;
max-lease-time 7200;
option subnet-mask 255.255.255.0;
option broadcast-address 10.0.0.255;
option routers 10.0.0.1;
option domain-name-servers 8.8.8.8;
option domain-name “freeinternet.co.uk”
}
Check that /etc/default/isc-dhcp-server has INTERFACES=”at0”
Start the DHCP Server:
/etc/init.d/isc-dhcp-server restart
Configure NAT and enable ip forwarding:
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables -P FORWARD ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "1" > /proc/sys/net/ipv4/ip_forward
At this stage I believe I should be able to connect a client to my access point and browse the web.
The client sees the access point, connects, gets an IP address from the server's DHCP (10.0.0.101) and then has the following routing table:
mark@laptop15:~/TT$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.0.1 0.0.0.0 UG 0 0 0 wlan0
10.0.0.0 0.0.0.0 255.255.255.0 U 9 0 0 wlan0
However it cannot even ping the server (10.0.0.1) - no errors, we just don't get the pings back:
mark@laptop15:~/TT$ ping 10.0.0.1
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
And it stays like that forever.
What am I doing wrong please?
|
Turns out it was network-manager interfering. Switched it off
service network-manager stop
and everything works fine.
I suspect there exists a less drastic solution than disabling it altogether, but it does what I need for now.
| Linux access point (airmon-ng/airmon-ng) not working |
1,307,090,858,000 |
How can I restrict a user on the SSH server to allow them only the privileges for SSH TUNNELING? i.e. So they cannot run commands even if they log in via SSH.
My Linux servers are Ubuntu 11.04 and OpenWrt.
|
On the server side, you can restrict this by setting their user shell to /bin/true. This will allow them to authenticate, but not actually run anything since they don't get a shell to run it in. This means they will be limited to whatever subset of things SSH is able to offer them. If it offers port forwarding, they will still be able to do that.
On the client side, you will probably want to connect with the -N. This stops the client from ASKING for a remote command such as a shell, it just stops after the authentication part is done. Thanks to commentors for pointhing this out.
| How to restrict an SSH user to only allow SSH-tunneling? |
1,307,090,858,000 |
How do I completely disable an account? passwd -l will not allow anyone to log into an account using a password but you can still log in via private/public keys. How would I disable the account completely? As a quickfix I renamed the file to authorized_keys_lockme. Is there another way?
|
The correct way according to usermod(8) is:
usermod --lock --expiredate 1970-01-02 <username>
(Actually, the argument to --expiredate can be any date before the current date in the format YYYY-MM-DD.)
Explanation:
--lock locks the user's password. However, login by other methods (e.g. public key) is still possible.
--expiredate YYYY-MM-DD disables the account at the specified date. According to man shadow 5 1970-01-01 is an ambiguous value and shall not be used.
I've tested this on my machine. Neither login with password nor public key is possible after executing this command.
To re-enable the account at a later date you can run:
usermod --unlock --expiredate '' <username>
| How do I completely disable an account? |
1,307,090,858,000 |
I am running vsftpd as ftp server on my linux (rasbian), I log in to the machine as a root user.
I would like to be still locked to using only /var/www, how can I configure vsftpd conf to accomplish it?
|
Method 1: Changing the user's home directory
Make sure the following line exists
chroot_local_user=YES
Set user HOME Directory to /var/www/ , if you want to change for existing user then you can use:
usermod --home /var/www/ username
then set required permission on /var/www/
Method 2: Use user_sub_token
If you don't want to change user's Home directory then you can use:
chroot_local_user=YES
local_root=/ftphome/$USER
user_sub_token=$USER
About user_sub_token:
Automatically generate a home directory for each virtual user, based on a template.
For example, if the home directory of the real user specified via guest_username is
/ftphome/$USER, and user_sub_token is set to $USER, then when virtual user test
logs in, he will end up (usually chroot()'ed) in the directory /ftphome/test.
This option also takes affect if local_root contains user_sub_token.
Create directory and set up permissions:
mkdir -p /ftphome/{test,user1,user2}
chmod 770 -R /ftphome
chown -R ftp. /ftphome
usermod -G ftp test
Once restart vsftpd and test your setup.
Sample success output:
[root@mail tmp]# ftp localhost
Connected to mail.linuxian.local.
220 (vsFTPd 2.0.5)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (localhost:root): test
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> mput vhosts
mput vhosts?
227 Entering Passive Mode (127,0,0,1,146,41)
150 Ok to send data.
226 File receive OK.
24 bytes sent in 3.3e-05 seconds (7.1e+02 Kbytes/s)
ftp> ls -rlt
227 Entering Passive Mode (127,0,0,1,97,90)
150 Here comes the directory listing.
-rw-r--r-- 1 787 787 24 Oct 11 19:57 vhosts
226 Directory send OK.
ftp> 221 Goodbye.
| Limit FTP access only to the /var/www with vsftpd |
1,307,090,858,000 |
I'm allowing a friend a local account on my machine, exclusively for SCP. Can I specify his account's shell as /bin/true, or in any other way limit the account, while still allowing SCP?
|
I recommend using rsync instead of scp. For users, it has many more useful features. On the server side, it comes with rrsync to allow synvc access inside a given directory, but no general shell access and no access to other directories.
Alternatively, you can restrict the account to only allow SFTP and not shell access. SFTP is a distinct access type in the SSH protocol, unlike rsync and scp which work by running a shell command on the server. (rrsync restricts access by only allowing one specific shell command, which only supports certain rsync transfers and nothing else.) SFTP access enables SFTP clients as well as SSHFS.
Historically, there were projects such as rssh and scponly, which you could set as user's shell, and then the user would only be able to run file copies and not get shell access. However, those projects are unmaintained and very likely insecure by now.
| Do you need a shell for SCP? |
1,307,090,858,000 |
How to block command, let say mkdir for specific user ?
What I did just created read-only function and store in users profile ~/.bashrc
/bin/mkdir() {
echo "mkdir command not allow for you"
}
mkdir() {
echo "mkdir command not allow for you"
}
./mkdir() {
echo "mkdir command not allow for you"
}
readonly -f /bin/mkdir
readonly -f mkdir
readonly -f ./mkdir
Test:
rahul@ubuntu:~$ cd /bin/
rahul@ubuntu:/bin$ ./mkdir /home/rahul/ggg
mkdir command not allow for you
rahul@ubuntu:/bin$ cd
rahul@ubuntu:~$ mkdir testing
mkdir command not allow for you
rahul@ubuntu:~$ /bin/mkdir testing
mkdir command not allow for you
So my question is What should be the way of achieving this ? is there any tool for this ?
Update 1 # But if user is smart , he could copy mkdir binary and rename it and use it . So how to achieve this ?
|
I don't know how to do it with bash, but I know of another shell that restricts the user environment: lshell (limited shell).
A quick overview of configuration
Lshell is configured via an INI file. By default, it holds a whitelist of allowed commands, but it can be easily configured to prohibit user from using a specific command.
This configuration (default conf /etc/lshell.conf) prohibits user foo from using mkdir:
[foo]
allowed = 'all' - ['mkdir', 'bash', 'sh', 'csh', 'dash', 'env']
In order to configure a user account to use lshell by default, you must:
chsh -s /usr/bin/lshell foo
Lshell can do more, like:
3 levels of granularity: user, group, all.
Can restrict access to certain paths in the system.
Can restrict the use of certain characters (like |).
Can restrict the use of certain commands only over SSH.
And more.
Update 1# Added Test Result :
rahul:~$ which bash
/bin/bash
rahul:~$ dd if=$(which bash) of=my_bash
*** forbidden syntax: dd if=$(which bash) of=my_bash
rahul:~$ bash
*** forbidden command: bash
rahul:~$ cp /bin/bash my_bash
*** forbidden path: /bin/bash
rahul:~$ /bin/bash
*** forbidden command: /bin/bash
rahul:~$ sh
*** forbidden command: sh
rahul:~$ dash
*** forbidden command: dash
rahul:~$ env bash
*** forbidden command: env
rahul:~$ cp /bin/mkdir mycreatedir
*** forbidden path: /bin/mkdir
| Block Particular Command in Linux for Specific user |
1,307,090,858,000 |
If a user has loginShell=/sbin/nologin is it still possible to
ssh user@machine [command]
assuming that the user has proper ssh keys in its home directory that can be used to authenticate?
My goal is to keep the user as a nologin, but still able to execute commands on a few other machines on the network (similar to its use through 'sudo -u'), and am wondering if this is a reasonable course.
|
Setting /sbin/nologin as the user's shell (or /bin/false or /bin/true, which are almost equivalent) forbids the user from logging in to run any command whatsoever. SSH always invokes the user's login shell to run commands, so you need to set the login shell to one that is able to run some commands.
There are several restricted shells that allow users to run only a few commands. For example rssh and scponly are both such shells that allow the user to run a few predefined commands (such as scp, sftp-server, rsync, …). See also Restrict user access in linux and Do you need a shell for SCP?
| Can a command be executed over ssh with a nologin user? |
1,307,090,858,000 |
I'm running a server, and I need to give read/write access to a particular directory to a single user. I've tried the following:
sudo adduser abcd
sudo groupadd abcdefg
chown -R .abcdefg /var/www/allowfolder
chmod -R g+rw /var/www/allowfolder
usermod -a -G comments abcd
The above seems to work, however it gives the user read-only access to the rest of the server.
How can I set up permissions so that the user can only read and write to a particular folder? The user should also be able to run programs like mysql.
|
Negative ACLs
You can prevent a user from accessing certain parts of the filesystem by setting access control lists. For example, to ensure that the user abcd cannot access any file under /home:
setfacl -m user:abcd:0 /home
This approach is simple, but you must remember to block access to everything that you don't want abcd to be able to access.
Chroot
To get positive control over what abcd can see, set up a chroot, i.e. restrict the user to a subtree of the filesystem.
You need to make all the files that the user needs (e.g. mysql and all its dependencies, if you want the user to be able to run mysql) under the chroot. Say the path to the chroot is /home/restricted/abcd; the mysql program needs to be available under /home/restricted/abcd. A symbolic link pointing outside the chroot is no good because symbolic link lookup is affected by the chroot jail. Under Linux, you can make good use of bind mounts:
mount --rbind /bin /home/restricted/abcd/bin
mount --rbind /dev /home/restricted/abcd/dev
mount --rbind /etc /home/restricted/abcd/dev
mount --rbind /lib /home/restricted/abcd/lib
mount --rbind /proc /home/restricted/abcd/proc
mount --rbind /sbin /home/restricted/abcd/sbin
mount --rbind /sys /home/restricted/abcd/sys
mount --rbind /usr /home/restricted/abcd/usr
You can also copy files (but then you'll need to take care that they're up to date).
To restrict the user to the chroot, add a ChrootDirectory directive to /etc/sshd_config.
Match User abcd
ChrootDirectory /home/restricted/abcd
You can test it with:
chroot --userspec=abcd /home/restricted/abcd/ /bin/bash
Security framework
You can also use security frameworks such as SELinux or AppArmor. In both cases, you need to write a fairly delicate configuration, to make sure you aren't leaving any holes.
| Give user read/write access to only one directory |
1,307,090,858,000 |
This is what I'd like to be able to do:
After a user's account is created, they should be able to ssh-tunnel, but their account is automatically removed after 30 days unless the countdown is reset by the root user.
How can I automate this? I'll have to handle around 15 users.
|
useradd
You can control how long a user's account is valid through the use of the --expiredate option to useradd.
excerpt from useradd man page
-e, --expiredate EXPIRE_DATE
The date on which the user account will be disabled. The date is
specified in the format YYYY-MM-DD.
If not specified, useradd will use the default expiry date specified
by the EXPIRE variable in /etc/default/useradd, or an empty string
(no expiry) by default.
So when setting up the user's account you can specify a date +30 days in the future from now, and add that to your useradd command when setting up their accounts.
$ useradd -e 2013-07-30 someuser
chage
You can also change a existing accounts date using the chage command. To change an accounts expiration date you'd do the following:
$ chage -E 2013-08-30 someuser
calculating the date +30 days from now
To do this is actually pretty trivial using the date command. For example:
$ date -d "30 days"
Sun Jul 28 01:03:05 EDT 2013
You can format using the +FORMAT options to the date command, which ends up giving you the following:
$ date -d "30 days" +"%Y-%m-%d"
2013-05-28
Putting it all together
So knowing the above pieces, here's one way to put it together. First when creating an account you'd run this command:
$ useradd -e `date -d "30 days" +"%Y-%m-%d"` someuser
Then when you want to adjust their expiration dates you'd periodically run this command:
$ chage -E `date -d "30 days" +"%Y-%m-%d"` someuser
Specifying time periods of less than 24h
If you want a user to only be active for some minutes, you cannot use the options above since they require specifying a date. In that case, you could either set up a crontab to remove/lock the created user after the specified time (for example, 10 minutes), or you could do one of:
adduser someuser && sleep 600 && usermod --lock someuser
or
$ adduser someuser
$ echo usermod --lock someuser | at now + 10 minutes
References
useradd man page
chage man page
| How can I create automatically expiring user accounts? |
1,307,090,858,000 |
How to add an ssh user who only has permissions to access specific folder?
useradd -d /var/www/xyz.com.tr/musteri -s /bin/bash -g sshd musteri
I created a user called musteri. I set its home folder and group.
So, I want to integrate musteri users into "/var/www/xyz.com.tr/musteri". I don't want it to access another folder.
|
It sounds like you want your müşteriler to have file transfer access to a folder without actually giving them shells. This is a good thing because as binfalse pointed out, giving people shells with limited access is tricky because shells need to access all kinds of things scattered on the system just to run.
In order to give SFTP access to a specific folder, you can do something like this.
Add a new group to the system, say 'sftponly'.
Add any users on your system that should have restricted rights to this group. You could also give them restricted shells like /bin/true, but it's not required.
Change your ssh config file (Usually /etc/ssh/sshd_config) with these lines
Subsystem sftp internal-sftp
Match Group sftponly
ChrootDirectory %h
AllowTCPForwarding no
X11Forwarding no
ForceCommand internal-sftp
This would activate the sftp subsystem inside of SSH and force members of that system group to use only that system when logging in. It would also chroot them to their home directories. You could change that to be a sub-folder of their home-directores as well with something like ChrootDirectory %h/musteri_sftp so that they couldn't se the rest of their system files but would login directly to a special subfolder of their home folder.
Kolay gelsin.
| How to add a ssh user who only has permissions to access specific folder? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.