Categories
Uncategorized

Importing Hyper-V backup

From the right pane in Hyper-V Manager Console, select the ‘Import Virtual Machine’ option.

Browse to the folder of your backed up VM and ‘Select Folder’

Choose the type of import to perform.

Complete the import

I’ve been noticing that in some cases when you added a new virtual switch manager other than the default ones in Hyper-V, the VM would fail to start with “Hyper-V Manager: failed to change state.”.

My workaround was doing another import but during the connection selection, selecting a connection for each VM.

Categories
Uncategorized

Creating Hyper-V backups in Windows 10

Download and run the script from Mike Galvin.

Create folder c:\scripts

Create folder c:\scripts\logs

Create folder c:\scripts\vms

Save code from: https://github.com/Digressive/HyperV-Backup-Utility/blob/master/Hyper-V-Backup.ps1 to file Hyper-V-Backup.ps1 in the folder c:\scripts

Create a text file called c:\scripts\vms.txt and on a separate line list each Hyper-V VM name you would like to backup.

Right click on powershell and run as administrator

Run: C:\scripts\Hyper-V-Backup.ps1 -BackupTo C:\scripts\vms C:\scripts\vms.txt -Keep 4 -L C:\scripts\logs

More options available such as compress and email.

Source: https://gal.vin/2017/09/18/vm-backup-for-hyper-v/

Schedule the task with Task scheduler

Open task scheduler by typing in taskschd.msc

Action > Create Task

Enter in a name like “Backup VMs”

Select “Run whether user is logged on or not”

Configure for: “Windows 10”

Tab Triggers

Daily, select start date / time

Stop task if it runs longer than: 4 hours (or whatever works for you)

Tab Actions

Enter “powershell” in program / script

Enter for “Add arguments (optional):” C:\scripts\Hyper-V-Backup.ps1 -BackupTo C:\scripts\vms C:\scripts\vms.txt -Keep 4 -L C:\scripts\logs

Tab Settings

Check the following:

“Allow task to be run on demand”
“Run task as soon as possible after a scheduled start is missed”
“Stop the task if it runs longer than: 4 hours (or whatever works for you)
“If the running task does not end when requested, force it to stop”

Categories
Uncategorized

Install Debian 10 with PHP 7 and MySQL 8 + phpMyAdmin

sudo: command not found

After installation of Debian 10 and you try to install a package you might get the message: bash: sudo: command not found

To install sudo, run the following:

su

apt-get install sudo

Give the user the right to run sudo

usermod -aG sudo username

Log out the user to refresh the group permissions of the user

Reference: https://chewett.co.uk/blog/477/sudo-command-not-found-debian-fixed/

Install the firewall ufw on Debian

Run the package installer:

sudo apt-get install ufw

Enable the firewall

sudo ufw enable

Reference: https://www.tecmint.com/how-to-install-and-configure-ufw-firewall/

Install the Apache Web Server

Update the local package index to reflect the latest upstream changes:

sudo apt update

Install the apache2 package

sudo apt install apache2

Configure the firewall for port 80

sudo ufw allow in 'WWW Full'

On your local computer you can check ‘localhost’ in the browser to see if Apache is running.

To test the install from another computer find the IP address of the server with:

ip addr show

Reference: https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-debian-9

Install MYSQL 8.0

MySQL 8.0 packages are available on the official MySQL Dev apt repository

sudo apt -y install wget
wget https://repo.mysql.com//mysql-apt-config_0.8.13-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb

sudo apt update
sudo apt -y install mysql-server

Reference: https://computingforgeeks.com/how-to-install-mysql-8-0-on-debian/

Install PHP7

sudo apt update 
sudo apt upgrade

sudo apt install php libapache2-mod-php php-gd php-mysqlnd

Create a PHP Info page to see if it is all working.

sudo nano /var/www/html/info.php

Type in:

<?php phpinfo(); ?>

Enter ctrl+x, y and enter

In your browser go to your https://webserver/info.php

Install phpMyAdmin

Log in to MySQL

mysql -u root -p

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'PASSWORD';

Update server’s package index

sudo apt update

sudo apt install php-mbstring php-zip php-gd

wget https://files.phpmyadmin.net/phpMyAdmin/4.9.0.1/phpMyAdmin-4.9.0.1-all-languages.tar.gz

tar xvf phpMyAdmin-4.9.0.1-all-languages.tar.gz

sudo mv phpMyAdmin-4.9.0.1-all-languages/ /usr/share/phpmyadmin

sudo mkdir -p /var/lib/phpmyadmin/tmp

sudo chown -R www-data:www-data /var/lib/phpmyadmin

sudo cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php

sudo nano /usr/share/phpmyadmin/config.inc.php

Add a 32 character blowfish_secret

$cfg['blowfish_secret'] = 'RANDOMSTRINGHERE'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

At the bottom of the file add

$cfg['TempDir'] = '/var/lib/phpmyadmin/tmp';

Configuring Apache to Serve phpMyAdmin

Create new file

sudo nano /etc/apache2/conf-available/phpmyadmin.conf

Add the following code:

# phpMyAdmin default Apache configuration

Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>
    Options SymLinksIfOwnerMatch
    DirectoryIndex index.php

    <IfModule mod_php5.c>
        <IfModule mod_mime.c>
            AddType application/x-httpd-php .php
        </IfModule>
        <FilesMatch ".+\.php$">
            SetHandler application/x-httpd-php
        </FilesMatch>

        php_value include_path .
        php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
        php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/
        php_admin_value mbstring.func_overload 0
    </IfModule>
    <IfModule mod_php.c>
        <IfModule mod_mime.c>
            AddType application/x-httpd-php .php
        </IfModule>
        <FilesMatch ".+\.php$">
            SetHandler application/x-httpd-php
        </FilesMatch>

        php_value include_path .
        php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
        php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/
        php_admin_value mbstring.func_overload 0
    </IfModule>

</Directory>

# Authorize for setup
<Directory /usr/share/phpmyadmin/setup>
    <IfModule mod_authz_core.c>
        <IfModule mod_authn_file.c>
            AuthType Basic
            AuthName "phpMyAdmin Setup"
            AuthUserFile /etc/phpmyadmin/htpasswd.setup
        </IfModule>
        Require valid-user
    </IfModule>
</Directory>

# Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/templates>
    Require all denied
</Directory>
<Directory /usr/share/phpmyadmin/libraries>
    Require all denied
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
    Require all denied
</Directory>

sudo a2enconf phpmyadmin.conf

sudo systemctl reload apache2

Log into phpMyAdmin: https://localhost/phpmyadmin

Create database phpmyadmin

Click operations tab – follow links to create tables for phpmyadmin database

Source: https://www.digitalocean.com/community/tutorials/how-to-install-phpmyadmin-from-source-debian-10

Install VSTFTPD

sudo apt update
sudo apt install vsftpd

sudo nano /etc/vsftpd.conf

Set the following in the vsftpd.conf file:

anonymous_enable=NO
local_enable=YES
local umask=022
userlist_enable=YES
userlist_file=/etc/vsftpd.user_list
userlist_deny=NO

Add ufw exceptions

sudo ufw allow 20:21/tcp
sudo ufw allow 30000:31000/tcp
sudo systemctl restart vsftpd

Add the users that are allowed to access vsftpd to the vsftpd.userlist (one per line)

sudo nano /etc/vsftpd.user_list

The following is ONLY for dev environment

Add current user to group that owns /var/www/html folder

sudo usermod -a -G GROUPNAME USERNAME

Reboot system

Change group permissions to rwx

sudo chmod -R g+rwx /var/ww/html

Categories
Uncategorized

Grant Sudo Privileges to Users on Debian

su root

sudo usermod -aG sudo USERNAME

Categories
Uncategorized

A stop job is running for …

When you are getting message such as:

“A stop job is running for Session”

“A stop job is running for User manager for UID”

I found that a quick workaround would be to logout the user first and then shutting down or in terminal enter:

sudo shutdown now

Categories
Uncategorized

Install Debian 9 with PHP 5.6 and MySQL 8

Due to the fact that php5.6-curl only works with libcurl3 and Debian 10 is shipped with libcurl4 with no option to downgrade lib curl, it appears you can only use Debian 9 when wanting to use the old PHP 5.6 and curl extensions.

Install updates for Debian

apt-get update

followed by

apt-get dist-upgrade

sudo: command not found

After installation of Debian 9.11 and you try to install a package you might get the message: bash: sudo: command not found

To install sudo, run the following:

su

apt-get install sudo

Give the user the right to run sudo

usermod -aG sudo username

Log out the user to refresh the group permissions of the user

Reference: https://chewett.co.uk/blog/477/sudo-command-not-found-debian-fixed/

Install the firewall ufw on Debian

Run the package installer:

sudo apt-get install ufw

To configure your server to allow incoming SSH connections, use this command:

sudo ufw allow ssh

Enable the firewall

sudo ufw enable

Reference: https://www.tecmint.com/how-to-install-and-configure-ufw-firewall/

Install the Apache Web Server

Update the local package index to reflect the latest upstream changes:

sudo apt update

Install the apache2 package

sudo apt install apache2

Configure the firewall for port 80

sudo ufw allow in 'WWW Full'

On your local computer you can check ‘localhost’ in the browser to see if Apache is running.

To test the install from another computer find the IP address of the server with:

ip addr show

Reference: https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-debian-9

Install MYSQL 8.0

MySQL 8.0 packages are available on the official MySQL Dev apt repository

sudo apt -y install wget
wget https://repo.mysql.com//mysql-apt-config_0.8.13-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb

If you get an error message “lsb-release is not installed.” – run the following:

sudo apt-get update
sudo apt-get install lsb-release

sudo apt update
sudo apt -y install mysql-server

Reference: https://computingforgeeks.com/how-to-install-mysql-8-0-on-debian/

Update the my.cnf file

Add the following information (depends based on your own requirements)
Setting innodb_dedicated_server=1 is an important one.

sudo nano /etc/mysql/my.cnf

[mysqld]
default_authentication_plugin=mysql_native_password
collation-server=utf8_unicode_ci
character-set-server=utf8
innodb_dedicated_server=1
innodb_flush_log_at_trx_commit=1
sync_binlog=1
local_infile=1
sql-mode="TRADITIONAL"
[client]
local_infile=1

Install PHP5.6

sudo apt update

sudo apt upgrade

sudo apt install ca-certificates apt-transport-https

wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -

echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list

sudo apt update
sudo apt install php5.6

sudo apt install php5.6-cli php5.6-common php5.6-curl php5.6-mbstring php5.6-mysqlnd php5.6-xml

Create a PHP Info page to see if it is all working.

sudo nano /var/www/html/info.php

Type in:

<?php phpinfo(); ?>

Enter ctrl+x, y and enter

In your browser go to your https://webserver/info.php

Reference: https://tecadmin.net/install-php-debian-9-stretch/

Install phpMyAdmin

sudo nano /etc/mysql/my.cnf

Add the following lines:

[mysqld]
default_authentication_plugin=mysql_native_password
collation-server=utf8_unicode_ci
character-set-server=utf8

Restart mysql server

sudo service mysql restart

Install phpmyadmin with

sudo apt install phpmyadmin php-mbstring php-gettext

Select apache2 by pressing SPACE, TAB and then enter

Configure database for phpmyadmin with dbconfig-common?

Choose no, as the installer will fail

Login to phpmyadmin with root

http://webserver/phpmyadmin

Create a new database called phpmyadmin, click on the Operations tab

Click ‘Create the phpMyAdmin configuration storage

Create an user called phpmyadmin

Choose ‘Native MySQL authentication’

For some reason after adding the user an error was generated, click on the phpmyadmin user, reenter the password and flush privileges.

Give user phpmyadmin full privileges to the database phpmyadmin

Setup SFTP

Using this method with the least amount of configuration, we will create a Match User directive in the SSH config and add your SFTP user to the www-data group.

Create user

sudo adduser webdev

Add Match User Directive in SSH Config

Restrict the user webdev to the document root and also disable their SSH access – we only want them to be able to log in over SFTP. We can do this by adding a Match User directive in the SSH config file.

Begin by opening sshd_config.

sudo nano /etc/ssh/sshd_config

Scroll down to the bottom of the SSH config file and add your new Match User directive.

Make sure that ChrootDirectory is the directory above your document root. For example, if your document root is /var/www/html/, then the ChrootDirectory is /var/www/.

If you followed one of our previous guides on hosting multiple domains on Apache or Nginx, your document root may be located in /var/www/mydomain.com/public_html, in that case, your ChrootDirectory would be /var/www/mydomain.com/.

Note you can add multiple users here separated by a comma, e.g. Match User webdev, webdev2, webdev3/etc/ssh/sshd_config

Match User webdev 
        ChrootDirectory /var/www/
        ForceCommand internal-sftp 
        X11Forwarding no 
        AllowTcpForwarding no 
        PasswordAuthentication yes

Save and exit (press CTRL + X, press Y and then press ENTER)

Test SSH config before restarting.

sudo sshd -t

If no errors, restart the sshd service for changes to take affect.

sudo service sshd restart

Setup SFTP

Add SFTP User to www-data

Add your SFTP user webdev to the www-data group.

sudo usermod -a -G www-data webdev

Note: Linux groups do not take affect until the user logs out and in again. If you are already logged in as this user in your FTP client, close the program completely and then log in again.

Set Directory Permissions

SFTP is very strict when it comes to chroot directory permissions and if they are not set correctly, you will not be able to login.

  • The chroot directory and all of its parents must not have group or world write capabilities. In other words, you must make sure /var/www/ is set to 755. (not 775, which gives group write permissions).
  • The chroot directory and all of its parents must be owned by root.

Assuming that your chroot is /var/www/, ensure that the directory is set to 755.

sudo chmod 755 /var/www/

Ensure your chroot directory is owned by root.

sudo chown root:root /var/www/

To check permissions for this directory:

sudo ls -ld /var/www/

Output:

drwxr-xr-x 14 root root 4096 Jun  3 14:28 /var/www/

Make sure the document root is set to 775, which will allow groups write to this directory.

sudo chmod 775 /var/www/html

Make sure that your document root and all contents are owned by www-data.

sudo chown -R www-data:www-data /var/www/html*

Change all directories in the document root to 775. This will allow both the owner (www-data) and its group (which SFTP users belong to) to read, write and execute folders.

sudo find /var/www/html/ -type d -exec chmod 775 {} \;

Change all filesin the document root to 664, this will allow both the owner and the group to read, write and execute files.

sudo find /var/www/html/ -type f -exec chmod 664 {} \;

Make sure that any new files or folders created by SFTP users inherit the www-data group.

sudo find /var/www/html -type d -exec chmod g+s {} \;

Now log into SFTP with you preferred FTP client and make sure you can create, edit and delete files and folders.

If you are not able to log in, check the auth log for the last 50 entries.

sudo tail -n 50 /var/log/auth.log

Adding More SFTP Users

If you need to provide other SFTP users write access to the document root, simply add their usernames separated by a comma, e.g. Match User webdev, webdev2, webdev3 in sshd_config (step 4.1) and then add the SFTP user to the www-data group .

Source: https://devanswers.co/configure-sftp-web-server-document-root/

Categories
Uncategorized

Quickbooks message: this action requires windows administrator permissions

On your Quickbooks server, go to Computer Management > Services

Scroll down till you find the listing for “QuickBooksDBXX” service.
Double click the service and then select the “Log On” tab.

Where it says “Log on as:” make sure the “Local System Account” button is selected instead of the \QBDataServiceUserXX account.

Categories
Uncategorized

Disk space is affected by local snapshots for Time Machine on MacOS

Your Time Machine backup disk might not always be available, so Time Machine also stores some of its backups on your built-in startup drive and other local drives. These backups are called local snapshots. One snapshot is saved every hour. If you’re using macOS High Sierra, another snapshot is saved before installing any macOS update.

Snapshots older than 24 hours are automatically deleted according to Apple, but I’ve seen snapshots many days old. And to make sure that you have storage space when you need it, snapshots are stored only on disks that have plenty of free space. When storage space gets low, additional snapshots are deleted, starting with the oldest. That’s why Finder and Get Info windows don’t include local snapshots in their calculations of the storage space available on a disk.

I think the concept is ok, however I don’t want / need it. There is currently no option to turn this ‘feature’ off. Also, I think it makes people think they don’t have enough disk space when looking at the disk utility app while they actually do have enough space available – another reason to upgrade to a new Mac.

The solution that worked for me is to run the following command in terminal:
tmutil listlocalsnapshotdates / |grep 20|while read f; do tmutil deletelocalsnapshots $f; done
The above command removes all the local snapshots. Warning, this will mess with the Timemachine Backups clearly – do it at your own risk.

More information about local snapshots here: https://support.apple.com/en-ca/HT204015

Categories
Uncategorized

Encountering Error code -43 while copying from a Network drive on MacOS

When I was copying files from a network drive to my local drive on a Mac I was receiving the error message:

The operation can’t be completed because one or more required items can’t be found.
(Error code -43)

It appears that there were some illegal characters used in the file names that cause the Finder copy to error out like that and stop the entire copy process completely.

The workaround is opening a Terminal window and entering:
cp -r sourcefolder destinationfolder/

You can simply drag and drop the source and destination folders into the terminal window to get the full path in there.

Using -r behind the cp (copy command) is necessary to ensure you go through the complete folder structure recursively.

The trailing slash at the end of the destinationfolder is necessary to ensure the folder destinationfolder gets created if it does not exist.

The copy process will now copy everything and give you a result of the files that could not be copied so you can change the filename and manually copy these over again.