Date and time
Setting the date and time correctly is important for validating connection certificates. If the date on the controller differs too much from the date on the machine that is trying to connect, you may not be able to connect and you may see NET:ERR_CERT_DATE_INVALID reported in your browser.
To set the correct time, log in to your controller via ssh. See Remote Access and file transfer.
Setting date and time
To check the current date and time, type the following in the terminal:
The date and time can be set by executing the following Linux command (as root):
sudo date -s "Mon Mar 15 18:49:40UTC 2019" sudo hwclock -w
The last line is important because only then the time is set correctly in the hardware clock and is not lost on reboot.
Setting date and time via ssh from a Linux host
You can also copy the date and time from a Linux machine to the target controller. You can do this from the controller or from the host machine; the first method is more secure since it does not require using the password in clear text.
Setting time from the controller
To execute the date setting from the controller, first log in to the controller via ssh:
You need to allow remote login via ssh on your host machine:
- If not installed:
sudo apt install openssh-server
- Start ssh service:
sudo service ssh start
- View ssh service status:
sudo service ssh status
- After set the time, stop ssh service:
sudo service ssh stop
Then run the following command, where you replace
[user] by the username and
[ip] by the hostname or ip address of the host machine where you would like to copy the time from:
sudo echo; D=$(ssh [user]@[ip] 'date -Ins'); sudo date -s $D; sudo hwclock -w
How to find host [user]/[ip]
Open terminal you see:
Open host computer network settings.
[ip] with filled in network adapter address
sudo echo; D=$(ssh firstname.lastname@example.org 'date -Ins'); sudo date -s $D; sudo hwclock -w
You will first be asked for the
password of the
host machine and then for the
password of the
Using this command the time on the controller should be set very close to the time of the target machine.
Setting time from the host (insecure!)
To avoid a delay between reading the time on the host and setting it on the target it is recommended to enable automatic ssh login via your public key. Copy your public key to the target like this (assuming your public key is in ~/.ssh/id_rsa.pub):
ssh-copy-id -i ~/.ssh/id_rsa.pub email@example.com
You have to enter the admin user’s password once to copy the key, after that connecting to the machine should not require your password any more.
Execute the following script to read the time in UTC on you local machine and set it via ssh on the remote machine. Since the
date -s command requires sudo you can pass the password in clear text by using the
echo command and the
-S switch for the
sudo command. Note that this is a security risk, you should not store this command anywhere and make sure your command history is cleared afterwards:
D=`date -Ins`; echo $D; ssh -t firstname.lastname@example.org 'echo vectioneer | sudo -S date -s '$D'; sudo hwclock -w'
To mitigate the risk of someone reading your password in the history delete the command history on your local machine by executing:
This should not be necessary on the controller, since executing ssh command on the remote machine does not add the command to that machine’s history.
Setting the Timezone
First, set the timezone by replacing the link
/etc/localtime with a link that points to the desired timezone:
sudo rm -f /etc/localtime sudo ln -sf /usr/share/zoneinfo/Universal /etc/localtime
Universal with your desired region or timezone.
The default setting is Universal Time.