Tuesday, April 11, 2023

Check if SSL CSR, Key and CRT match

To view the md5 hash of the modulus of the private key:

$ openssl rsa -noout -modulus -in mykey.key | openssl md5

To view the md5 hash of the modulus of the CSR:

$ openssl req -noout -modulus -in mycsr.csr | openssl md5

To view the md5 hash of the modulus of the certificate:

$ openssl x509 -noout -modulus -in mycert.crt | openssl md5

If all three hashes match, the CSR, certificate, and private key are compatible. You can use 

diff3
 to compare the moduli from all three files at once:

$ openssl req -noout -modulus -in mycsr.csr > csr-mod.txt
$ openssl x509 -noout -modulus -in mycert.crt > cert-mod.txt
$ openssl rsa -noout -modulus -in mykey.key > privkey-mod.txt
$ diff3 csr-mod.txt cert-mod.txt privkey-mod.txt

If all three files are identical, 

diff3
 will produce no output.

Tuesday, March 7, 2023

Quickly Expand Linux Volume

 There are various complicated ways to expand a Linux volume. Here is an easy one using parted.

First, use command lsblk to show disk volume info, for example:

$ lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0           2:0    1    4K  0 disk 
sda           8:0    0   40G  0 disk 
├─sda1        8:1    0    1G  0 part /boot
└─sda2        8:2    0   19G  0 part 
  ├─cl-root 253:0    0   17G  0 lvm  /
  └─cl-swap 253:1    0    2G  0 lvm  [SWAP]

To expand cl-root volume, enter command:
parted ---pretend-input-tty /dev/sda resizepart 2 100%;
partx -u /dev/sda; pvresize /dev/sda2;
lvextend -r /dev/cl/root /dev/sda2
If the command does not work, just update parted by yum update parted. This works in CentOS 7.

Tuesday, January 10, 2023

Share mapped network drive for all users

 Normally a shared network drive is only accessible to the user who mapped it. Even when you use net use command in Command Prompt or PowerShell to map a network drive as Administrator, you will be surprised to find the drive is only available within the elevated Command Prompt or PowerShell window itself. It will not show in File Explorer.

In a small network environment, it is useful to allow all users using the same computer have ready access to the same mapped network drive, for example you have a team file server. You could use a login script to map drives for each and every user, or use a registry setting to share the mapped drive for all users.

Just create HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLinkedConnections DWORD and set the value to 1. Restart the computer to take effect.

You could use File Explorer to map network drives, or use command to do the same with option to enter different credential for access.

net use z: \\file_server\share_name password_here /user:username_here /persistent:Yes