Validating /etc/crontab

cron parses crontab every minute. In order to check crontab for syntax errors, check the logs output:

sleep 60; grep crontab /var/log/syslog | tail

Error “The Recovery server could not be contacted.” when reinstalling macOS High Sierra.

Received the error “The Recovery server could not be contacted.” when reinstalling macOS High Sierra on a laptop which has not be used for quite a while.

Turns out the battery had been completely drained, causing the laptops internal clock to reset to NSDate’s default value (00:00:00 UTC on 1 January 2001).

I assume that the machine connects to the recovery servers over HTTPS. As such, the server’s certificate can not be verified because the date is too far off from the actual date. One might ask why Apple do not make things easier and simply update the time using NTP before accessing the update server — doing so might enable an attacker to execute an mitm attack. The least Apple could do is to ask the user to input a correct date. Which leads us to the following solution.

To fix this, access the terminal from within the recovery GUI and execute

date mmddHHMMyy

where:

  • mm is the month [01;12],
  • dd is the day of month [01;31],
  • HH is the hour of day [00;23],
  • MM is the minute of the hour [00:59], and
  • yy is the year [00;99].

Then try again to launch internet recovery.

Adding a new bhyve guest to FreeBSD 11.1

Installing a guest on FreeBSD’s bhyve, assuming bhyve has previously been installed and is hosting at least one vm.

The guest’s hostname will be mailpile, its shall have 100GiB of storage and 2048 MiB of RAM.

# Obtain a list of iso's known to bhyve.
vm iso

# Create debian Linux guest. It shall have the hostname mailpile and have access to 100GiB of storage space.
vm create -t debian -s 100G mailpile

# Autostart the guest when the system comes up.
add mailpile to vm_list in /etc/rc.conf

# Configure the guest (add more RAM to it, I used 2048M).
vm configure mailpile

# Install debian to the guest. Spell out an iso file from "vm iso".
vm install mailpile debian-...myversion.iso

# Connect to the guest.
vm console mailpile

You should now be in the Debian installer.

(Installing) and configuring ftpd on FreeBSD 11.1

FreeBSD contains an ftp daemon in its base system; An FTP server is already installed and available on FreeBSD.

To enable the ftpd:
append the following line to /etc/rc.conf

ftpd_enable="YES"

To start the service, execute the following command:

service ftpd start

Installing ftp and telnet on macOS High Sierra (and later versions).

Apparently, ftp and telnet have been removed from macOS High Sierra. Apple claim this is for security reasons.

Both ftp and telnet can be obtained from the GNU inetutils package, which is available in macports.

Given that macports is available on the system, install GNU inetutils by executing:

sudo port install inetutils

An execution of the above commands installs ftp and telnet under /opt/local/bin/

Two ways to write my name in Unicode

I find it interesting that there are two ways to write my name, Pétur in Unicode.

One in which the e and ´ characters are combined into é:

petur:~ petur$ cat a;hexdump a
Pétur
0000000 50 c3 a9 74 75 72 0a                           
0000007

And another in which e is followed by a ´ (they are drawn in place).

petur:~ petur$ cat b;hexdump b
Pétur
0000000 50 65 cc 81 74 75 72 0a                        
0000008

diff reports a difference in the two:

petur:~ petur$ diff a b
1c1
< Pétur
---
> Pétur
petur:~ petur$ diff -q a b
Files a and b differ

Curious as to how C# and Swift treat the strings, I checked. The two do not agree on my name containing the character é.

// C# Code
string name = @"P\u0065\u0301tur";

// (e followed by ´ from keyboard) prints false
Console.WriteLine(name.Contains(@"é")); 

// (unicode for e followed by ´ from keyboard) prints false
Console.WriteLine(name.Contains(@"\u0305"));
// Swift Code
let name = "P\u{65}\u{301}tur"

// (e followed by ´ from keyboard) prints true
print(name.contains("é")) 

// (unicode for e followed by ´ from keyboard) prints false
print(name.contains("\u{0305}"))

FreeBSD bhyve guest networking stopped working after configuring host NIC aggregation.

Problem

A bhyve guest is unable to connect to the network after it’s host was configured to use NIC aggregation.

Analysis

The guest’s vm switch was configured to use one of the NIC aggregation’s ports instead of the interface itself.

This was evident by:

[root@T20][~]# vm switch list
NAME    TYPE    IDENT    VLAN    NAT    PORTS
public  auto    bridge0  -       -      em0

In the above listing, public should be using lagg0.

Solution

Remove the em0 port from public and add lagg0 to it:

vm switch remove public em0

vm switch add public lagg0

At this step I choose to simply restart the guest after which it was back on the network.

Passwordless SSH

Tired of having to retype your password each time you login to that remote computer?
Let me show you how to setup passwordless ssh.
Generate public and private keys on your client computer. Leave the passphrase empty.

user@local:~$ ssh-keygen -t rsa

Distribute your public key (~/.ssh/id_rsa.pub) to each servers .ssh/authorized_keys file.
user@local:~$ cat ~/.ssh/id_rsa.pub | ssh user@servername 'tee -a .ssh/authorized_keys'
 
Security concerns: If someone gets hold of your private key AND your left the passphrase empty, the he will have access to all of the remote computers just as you.


[ad#Google Adsense-1]

How to : Install Ubuntu onto software RAID0

Found this nifty article which explains how to install Ubuntu onto software raid 0
Requirements:
2 hard-drive, best if they are identical.
Ubuntu liveCD
1.
Boot into a live cd
2.
Install “mdadm” and remove “dmraid” (the latter causes some of my drives to not show up in the installer).

sudo apt-get update
sudo apt-get install mdadm
sudo apt-get remove dmraid

3.
Partitioning the two drives:
– Start the gparted partitioning manager
– Create a 500 MB partition on the “first” drive (“/dev/sda” + “/dev/sdb” = “/dev/sda” is the first one, but you can use any…I think)
– Create the main (“/”) partition on both drives, it’s size should be the rest of the free space minus the space used in the above partition and the swap partition beneath. Remember, this and the next partitions needs to be of equal size on both drives.
– The next partition is for your swap space. Create them with the same size as your RAM (combined they then will become doubled the space of your RAM).
It’s important you are aware what partitions are what “names”, sdb1 etc. You can also use different partitions sizes off course, as long as they have “enough” space.
[ad#Google Adsense-1]
4.
Create the raids:

sudo mdadm –create /dev/md0 –verbose –level=0 –raid-devices=2 /dev/sda2 /dev/sdb1
sudo mdadm –create /dev/md1 –verbose –level=0 –raid-devices=2 /dev/sda3 /dev/sdb2

5.
Format the new raids, or else the install application will want to alter the partition table, on the swap raid partition at least in my experience.

sudo mkfs.ext4 /dev/md0
sudo mkswap /dev/md1

6.
Start the installer (on the desktop), but DON’T reboot in the end when it asks!!!
– Complete the steps…
– …until you get to the partitioning, choose the advanced option at the bottom.
– Choose “/dev/md0” and click change, choose ext4 (or what ever you want) in the dropdown menu, choose to format and choose mount point “/”.
– Choose “/dev/md1” and click change, choose swap (now the rest is greyd out?)
– Choose the 500MB partition, click change: ext4, format, “/boot”
– IMPORTANT! When you arrive at the summary page (after entering name, password etc), click advanced at bottom right, and choose the drive where the 500MB partition is located (“sda”, “sdb” etc….but NOT “sda1”, “sdb1” etc), this is where grub, the boot loader, will be installed.
– The pair partitions will show in black as unknown with a warning sign…just ignore this, it’s ok (assuming the drives doesn’t have additional problems).
You can skip the step on the summary page, but then the Ubuntu installer will install the boot loader on what ever drive it considers the first drive. This should be technically ok, but I prefer to keep Linux separate, had the Win7 connected, so it was detected by Grub.
[ad#Google Adsense-1]
7.
We now need to do some stuff on the installed Linux, but before we boot off it because it can’t boot before we do. So we will mount it and “log” into it.

sudo mount /dev/md0 /target/
sudo mount –bind /dev/ /target/dev/
sudo mount –bind /sys/ /target/sys/
sudo mount –bind /proc/ /target/proc/
sudo mount –bind /dev/sda1 /target/boot/
sudo chroot /target

Notice the underlined part, you have to point it to the 500MB partition you created.
IMPORTANT: In Ubuntu 11.04, use the mounted dir, and not /dev/sda1.
“/media/7feb0b41-e0c2-4d98-b83e-f5f8f7b2e94b” <- example

sudo apt-get update
sudo apt-get remove dmraid
sudo apt-get install mdadm
sudo grub-install /dev/sda

Again, notice the underlined part, do the same as above, where is the 500MB partition?
Update: Notice that “dmraid” is now removed. A bird told me that it could interfere with mdadm. I installed/kept it, but you should probably remove it. Please tell me if this messes up things!
Update 2: Ubuntu 11.04 doesn’t have dmraid, so nothing to remove 
8.
Reboot and remove the live cd/usb stick. If you have set the BIOS to boot from the correct HDD, your Linux Raid 0 setup should start 
 
source: http://ubuntuforums.org/showthread.php?t=1551087