How to convert a PFX to a seperate .key/.crt file

In this article I’m going to show you the commands you need to convert your .PFX Certificate file to a seperate certificate and keyfile. This article can come in handy when you need to import your certificates on devices like Cisco routers/loadbalancers etc. where you probably need to import the certificates and keyfiles in plain text (unencrypted). My tool of choice (but there might be others) is OpenSSL for Windows, which can be downloaded here

So after you installed OpenSSL you can start it from it’s Bin folder. I’d like to put OpenSSL\Bin in my path so I can start it from any folder. Fire up a command prompt and cd to the folder that contains your .pfx file. First type the first command to extract the private key:

openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]

What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file.  This is the password that you used to protect your keypair when you created your .pfx file.  If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!.  Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file.

Now let’s extract the certificate:

openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]

Just press enter and your certificate appears.

Now as I mentioned in the intro of this article you sometimes need to have an unencrypted .key file to import on some devices.  I probably don’t need to mention that you should be carefully. If you store your unencrypted keypair somewhere on an unsafe location anyone can have a go with it and impersonate for instance a website or a person of your company.  So always be extra careful when it comes to private keys! Just throw the unencrypted keyfile away when you’re done with it, saving just the encrypted one.

The command:

openssl rsa -in [keyfile-encrypted.key] -out [keyfile-decrypted.key]

Again you need to enter an import password. This time you need to enter the new password that you created in step 1.  After that you’re done. You decrypted your private key. In the folder you ran OpenSSL from you’ll find the certifcate (.crt) and the two private keys (encrypted and unencrypted).

Update 07-07-2014:

In some cases you might be forced to convert your private key to PEM format. You can do so with the following command:

openssl rsa -in [keyfile-encrypted.key] -outform PEM -out [keyfile-encrypted-pem.key]

via: https://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/

 

Access your Virtualbox Guest from your Host OS

As a developer you want to ping and access the webserver on your virtual machine. This is a very simple solution to enable the bridge to the guest VM.

Requirements

  • VirtualBox (latest version)
  • A guest operation system (e.g. Ubuntu)

Setup

  • Shut down all running VM’s
  • Right click on the VM > Change… > Network
  • Open Tab: Adapter 1
  • Enable the Adapter and select “NAT”

The next step is importand to make it work:

  • Open Tab: Adapter 2
  • Enable the adapter and select: “Host-only Adapter”
  • Select Name: “VirtualBox Host-only Ethernet Adapter”
  • Click at “Extended”
  • Select the adapter: “Intel PRO/1000 MT Desktop…”
  • Select the modus: “Allow all and host”
  • Click on “Ok” to save all settings.

Yes, you have to enable two adapters at the same time to make it work. Realy. You need a “NAT” and a “Host-only Adapter”.

  • Start the VM
  • Open the terminal (with Ctrl+Alt+T)
  • Enter: ifconfig
  • Now you should see a local IP addresse like: 192.168.56.104
  • The IP address is dynamic an can be different on your VM

Test

  • Go back into your host machine
  • Open the command line: cmd
  • Ping the guest VM with the command: ping 192.168.56.104
  • You should see the ping response
  • If you have a webserver installed on the guest VM then open http://192.168.56.104 in your browser to the hosted website.

https://gist.github.com/odan/48fc744434ec6566ca9f7a993f4a7ffb

grant permissions to windows cluster object via the container to enable MSSQL Cluster installation.

CNO = When the Windows Failover Cluster (WFC) is initially configured a Cluster Name object (CNO) will be created. this is the windows cluster object in the AD.

1. Open the Active Directory Users and Computers Snap-in (dsa.msc).

2. Locate “Computers” container:

3. Make sure “Advanced Features” is selected:

4. Open the properties of the container and click the “Security” tab. Click “Add” and add the CNO. Make sure to select “Computers” option in the “Object Types” window:

5. Click “Advanced”, highlight the CNO, and click “Edit”:

6. Make sure “Read all properties” and “Create Computer objects” are checked. Click OK until you’re back to the AD Users and Computer window:

7. Retry your previously failed installation. Note that with SQL Server 2012 there will be a “retry” button.

via Error during installation of an SQL server Failover Cluster Instance – CSS SQL Server Engineers

Create a local user and assigning permissions on an ESXi host

  1. Create a local user on your ESXi host.

    Note: You cannot perform this task on vCenter Server.

    To create a local user on your ESXi host:

    1. Connect directly to the ESXi host using the vSphere Client.
    2. Click the Local Users & Groups tab.
    3. Right-click the window pane and and click Add.
    4. Enter a login name and a password (user name and UID is generated automatically if you leave the fields blank).
  2. Create a role and assign permissions:
    1. Select Home.
    2. Click Roles and click Add to create a new role with dedicated permissions.
    3. Define a name for the new role and select the necessary permissions.
  3. Assign the new role to the user:
    1. Select Inventory.
    2. Right-click the Permissions tab and click Add Permission.
    3. At the left pane, select Add to add the created user.
    4. At the right pane, select the new created role.

How to Convert a Virtual Disk from Thin to Thick

via VMware vSphere 4 – ESX and vCenter Server

Convert a Virtual Disk from Thin to Thick
If you created a virtual disk in the thin format, you can convert it to thick.
The thin provisioned disk starts small and at first, uses just as much storage space as it needs for its initial operations. After having been converted, the virtual disk grows to its full capacity and occupies the entire datastore space provisioned to it during the disk’s creation.
Procedure

1. Select the virtual machine in the inventory.

2. Click the Summary tab and, under Resources, double-click the datastore for the virtual machine to open the Datastore Browser dialog box.

3. Click the virtual machine folder to find the virtual disk file you want to convert. The file has the .vmdk extension.

4.Right-click the virtual disk file and select Inflate.

The virtual disk in thick format occupies the entire datastore space originally provisioned to it.

How to Find The Largest Top 10 Files and Directories On a Linux

via How Do I Find The Largest Top 10 Files and Directories On a Linux / UNIX / BSD? – nixCraft

https://www.tecmint.com/find-top-large-directories-and-files-sizes-in-linux/

Sometimes it is necessary to know what file(s) or directories are eating up all your disk space. Further, it may be required to find out it at the particular directory location on filesystem such as /tmp/ or /var/ or /home/. This guide will help you to use Unix and Linux command for finding the largest or biggest the files or directories on filesystem.

There is no simple command available to find out the largest files/directories on a Linux/UNIX/BSD filesystem. However, combination of following three commands (using pipes) you can easily find out list of largest files:

  • du command : Estimate file space usage.
  • sort command : Sort lines of text files or given input data.
  • head command : Output the first part of files i.e. to display first 10 largest file.
  • find command : Search file.

Type the following command at the shell prompt to find out top 10 largest file/directories:

# du -a /var | sort -n -r | head -n 10

Sample outputs:

1008372 /var
313236 /var/www
253964 /var/log
192544 /var/lib
152628 /var/spool
152508 /var/spool/squid
136524 /var/spool/squid/00
95736 /var/log/mrtg.log
74688 /var/log/squid
62544 /var/cache

If you want more human readable output try (GNU user only):

$ cd /path/to/some/where
$ du -hsx * | sort -rh | head -10

Where,

  • du command -h option : display sizes in human readable format (e.g., 1K, 234M, 2G).
  • du command -s option : show only a total for each argument (summary).
  • du command -x option : skip directories on different file systems.
  • sort command -r option : reverse the result of comparisons.
  • sort command -h option : compare human readable numbers. This is GNU sort specific option only.
  • head command -10 OR -n 10 option : show the first 10 lines.

The above command will only work of GNU/sort is installed. Other Unix like operating system should use the following version (see comments below):

for i in G M K; do du -ah | grep [0-9]$i | sort -nr -k 1; done | head -n 11

Sample outputs:

179M .
84M ./uploads
57M ./images
51M ./images/faq
49M ./images/faq/2013
48M ./uploads/cms
37M ./videos/faq/2013/12
37M ./videos/faq/2013
37M ./videos/faq
37M ./videos
36M ./uploads/faq

Find the largest file in a directory and its subdirectories using the find command

Type the following GNU/find command:

#Warning: only works with GNU find #
find /path/to/dir/ -printf ‘%s %p\n’| sort -nr | head -10
find . -printf ‘%s %p\n’| sort -nr | head -10

Sample outputs:

5700875 ./images/faq/2013/11/iftop-outputs.gif
5459671 ./videos/faq/2013/12/glances/glances.webm
5091119 ./videos/faq/2013/12/glances/glances.ogv
4706278 ./images/faq/2013/09/cyberciti.biz.linux.wallpapers_r0x1.tar.gz
3911341 ./videos/faq/2013/12/vim-exit/vim-exit.ogv
3640181 ./videos/faq/2013/12/python-subprocess/python-subprocess.webm
3571712 ./images/faq/2013/12/glances-demo-large.gif
3222684 ./videos/faq/2013/12/vim-exit/vim-exit.mp4
3198164 ./videos/faq/2013/12/python-subprocess/python-subprocess.ogv
3056537 ./images/faq/2013/08/debian-as-parent-distribution.png.bak

You can skip directories and only display files, type:

find /path/to/search/ -type f -printf ‘%s %p\n’| sort -nr | head -10

OR

find /path/to/search/ -type f -iname “*.mp4” -printf ‘%s %p\n’| sort -nr | head -10

Hunt down disk space hogs with ducks

Use the following bash shell alias:

alias ducks=’du -cks * | sort -rn | head’
Run it as follows to get top 10 files/dirs eating your disk space:
$ ducks

 

 

Which Files Should You Back Up On Your Windows PC?

via Which Files Should You Back Up On Your Windows PC?

Your PC’s hard drive could fail tomorrow, or a software bug could erase your files, so backups are critical. But you don’t need to back up all the files on your PC. That would just waste space and make your backups take longer to complete.

The All-Important Rule of Backups

The most important rule of backups is that any important data should exist in two or more physical locations at once. You cannot create a backup and delete the original. If you do, it’s no longer really a backup. You still have just one copy of your data—you just moved it to a different place.

You might think this is obvious, but you’d be surprised how often we’ve been approached by readers that lost their data after their “backup” drive died.

There are many ways to back up your data, from backing up to an external drive to uploading copies of your data to a remote server over the Internet. You can use the tools integrated into Windows or download a third-party backup tool. Choose the best backup solution that works for you—we discuss some of our favorites here.

We also recommend using multiple types of backups for maximum data security. For example, if you store your sole backup drive next to your computer, you’ll lose all copies of your files if your hardware is ever stolen or damaged in a fire. So having a backup in the cloud is a good idea.

Back Up Your Files, Not Your Full System

There are two types of backups you can create. Most common backup tools will back up a list of files and folders you specify. This allows you to back up just the files and folders you need. Your backups won’t be any larger than they need to be, and they’ll complete quickly.

However, it’s also possible to create full system image backups of your computer’s hard drive using built-in or third-party tools. These will back up everything, from your Windows system directory and installed program files to your personal data. These backups will be much larger and take much longer to create.

For most people, we recommend you stick with just backing up your files and folders. System image backups sound nice, but there are some big catches. For example, you can’t easily restore a system image on another computer, as a Windows installation will generally only run properly on its original system. You’re better off just starting from a fresh Windows installation and reinstalling your programs.

System image backups have their place, but avoid them unless you’re sure you need them. They’re not the best general purpose backup solution.

Files You Should Back Up

The most important thing is to back up your personal files. On a modern Windows PC, you’ll generally find these under C:\Windows\USERNAME, where USERNAME is your user account name.

By default, this directory contains your user account’s data folders. These include the Documents folder where your documents are saved to by default, the Pictures folder that likely contains any family photos you have, the Downloads folder where files are downloaded, the Music folder where your music files are probably stored, and the Videos folder where videos are stored. If you use iTunes for your music, iTunes stores its music library in your music folder by default. It even includes your Desktop folder, where many people store files.

It also includes other important folders, like OneDrive, Dropbox, and Google Drive, where offline copies of your cloud files are stored if you use these services.

There’s also an AppData folder here, but you won’t see it unless you’re showing hidden files and folders. This is where programs store the settings and data specific to your user account. You may be able to use this data to restore an individual program’s settings if you ever need to recover from a backup.

With that in mind, we recommend you back up your entire user account directory, including the hidden AppData folder. This ensures you have all your personal files and settings, and you don’t have to spend much time thinking about it. If multiple people use the same PC and have their own files, back up each user account’s folder.

You may choose to exclude certain folders from the backup if you don’t want them present. For example, if you store a bunch of downloaded videos in the Videos folder and you don’t mind redownloading them in the future, exclude it from the backup. If you have a many gigabytes of virtual machines that take a large amount of space and you wouldn’t mind setting them up from scratch again, exclude the virtual machine folder. But, if those virtual machines are important and it would take you a good amount of time to configure them again, you probably want to back them up.

You’ll notice that we’re using a lot of words like “by default”, “likely”, and “probably” when saying where your files are stored. That’s because Windows lets you store your files in any location you like. If you moved them, only you know where all your files are stored.

For example, it’s easy to move a folder like Music, Videos, Downloads, Pictures, or Documents to another location on your PC. These files may be stored on another drive, for example. Or you may not use the default folders at all and simply dump files in a folder elsewhere on your PC’s hard drive. If you store your files in non-standard locations like this, it’s crucial you identify the folders containing your important files and add them to the backup.

Your browser’s bookmarks and other settings are located somewhere in the AppData folder, so backing up your entire user folder will save these files as well. However, you may want to use your browser’s sync feature and sync its settings with a Google, Firefox, or Microsoft account. This will save you from having to dig through your AppData folder.

If you use a desktop email client, you may also want to back up your emails. This isn’t necessary if you use the modern IMAP protocol for your email, as the master copies of your emails are still stored on the remote server. However, if you’ve downloaded emails via the POP3 protocol, it’s crucial you back up your emails as they may only be stored on your PC.

The good news is that your emails are likely stored in your user account’s AppData folder, so they’ll be automatically backed up if you back up your entire user folder. You may still want to check the location of your email files just to ensure they’re backed up, however. Here’s how to find the location where Outlook stores your emails.

Any other personal data and settings that aren’t located in your user account folder should be backed up, if you care about it. For example, you may want to back up application settings that are located in the C:\ProgramData folder for some applications.

PC games in particular have files all over the place. Many games synchronize their save files online using Steam Cloud or a similar service, so they won’t need backups. Many store their save games in your Documents or AppData folders, while others dump their save games in C:\ProgramData or another location, like somewhere in your Steam folder. The PCGamingWiki website has a good database of games with information about whether they synchronize their save games or not and exactly where their save files are located on your PC.

Ensure whatever data you care about—whether it’s your family photos, settings for a mission-critical application, or save games for that RPG you’ve been playing for 100 hours—is backed up.

Files You Shouldn’t Back Up

There’s never a reason to back up your Windows directory or Program Files folder. Leave these folders alone.

The Windows directory contains Windows system files, and they aren’t portable between different PC hardware. Windows will set up these files when it’s installed on a new PC, so you don’t need them.

The Program Files folder contains files for your installed applications. You usually can’t just copy these folders over. You’ll have to reinstall most applications from scratch, so there’s generally no point in backing up this folder.

A handful of programs can be simply moved between PCs. For example, you can back up your Steam or Battle.net directories and copy them over to a new PC, saving the big download of these games. However, even these folders aren’t critical to back up. They can make setting up a new PC faster and save some of download time, but they aren’t full of critical files you can never get back. You can always just reinstall your programs, so they aren’t the priority if you’re limited on space.

Back Up Regularly

Once you’ve started backing up your files, you should continue creating regular backups. Back up your files daily, if possible. This will be a fast process if you back up regularly, as your backup tool will just back up the few personal files that have changed.

Automating your backups helps ensure those backups get performed regularly. That’s one reason why online backup solutions are so good. They can be configured to automatically back up your PC every day when you aren’t using your computer, so you won’t even have to think about it.

How to calculate file download time

via A Guide to Internet Connection Speeds

Bits and bytes explained

Can’t tell your bits from your bytes? Read on to learn the lingo.

Connection speeds and data sizes are measured differently, but people tend refer to them with the same names. People often say ‘megs’ and forget that the word ‘meg’ refers to two very different values. Do they mean megabits or megabytes? Aren’t they the same?

Actually no, there’s a big difference between a bit and a byte. A byte is much bigger — eight times bigger, in fact, with eight bits in every byte. By extension, there are eight megabits in every megabyte, and one gigabyte is eight times bigger than one gigabit.

You’re losing me with all this maths. How does this relate to me?

Let’s say you find a file online that is 24 megabytes (MB) in size, and you want to download it using your 24 megabit per second (Mbps) broadband connection. This won’t take one second, it will take eight times one second because a MB is eight times bigger than a Mb. So in theory (and with a perfect speed), it will take eight seconds to download.

How do I know if it’s a bit or a byte?

From how it is spelt. A byte is an uppercase ‘B’ and a bit is a lowercase ‘b’. If it says MB, all capitals, then it is a megabyte. If it says Mb, then it is a megabit. There is one exception to this, of course, and it is the symbol for kilobit, which is ‘kb’, all lowercase.

What other measurements should I know?

For practical purposes, you will only need to know a little bit (no pun intended). Kilos, megas, gigas and teras should see you through for the next few years or so.

KB, MB, GB – A kilobyte (KB) is 1,024 bytes. A megabyte (MB) is 1,024 kilobytes. A gigabyte (GB) is 1,024 megabytes. A terabyte (TB) is 1,024 gigabytes.

kb, Mb, Gb – A kilobit (kb) is 1,024 bits. A megabit (Mb) is 1,024 kilobits. A gigabit (Gb) is 1,024 megabits. A terabit (Tb) is 1,024 gigabits.

Don’t forget! There are eight bits in a byte, so to translate from one to the other, you can multiply or divide by eight. For example, if you want to transfer 1MB across a 1Mbps connection it will take eight seconds.

 

 

Extend a logical volume in a virtual machine running Red Hat or Cent OS

Source: Extending a logical volume in a virtual machine running Red Hat or Cent OS (1006371) | VMware KB

By default installation, Linux virtual machine (Fedora, RHEL or CentOS) has two partitions, one for swapping, and the other one is a lv (Logic Volume) partition.

The LVM (Logic Volume Manager) partition mount as /, and cannot be resized by partition tools such as partition magic or gparted.

To extend the logical volume:

Note: These steps only apply to EXT3 file systems.

 

Caution: VMware recommends to take a complete backup of the virtual machine prior to making these changes.

  1. Power off the virtual machine.
  2. Edit the virtual machine settings and extend the virtual disk size. For more information, see Increasing the size of a virtual disk (1004047).
  3. Power on the virtual machine.
  4. Identify the device name, which is by default /dev/sda, and confirm the new size by running the command:

    # fdisk -l

  5. Create a new primary partition:
    1. Run the command:

      # fdisk /dev/sda (depending the results of the step 4)

    2. Press p to print the partition table to identify the number of partitions. By default, there are 2: sda1 and sda2.
    3. Press n to create a new primary partition.
    4. Press p for primary.
    5. Press 3 for the partition number, depending on the output of the partition table print.
    6. Press Enter two times.
    7. Press t to change the system’s partition ID.
    8. Press 3 to select the newly creation partition.
    9. Type 8e to change the Hex Code of the partition for Linux LVM.
    10. Press w to write the changes to the partition table.
  6. Restart the virtual machine.
  7. Run this command to verify that the changes were saved to the partition table and that the new partition has an 8e type:

    # fdisk -l

  8. Run this command to convert the new partition to a physical volume:

    Note: The number for the sda can change depending on system setup. Use the sda number that was created in step 5.

    # pvcreate /dev/sda3

  9. Run this command to extend the physical volume:

    # vgextend VolGroup00 /dev/sda3

    Note: To determine which volume group to extend, use the command vgdisplay.

  10. Run this command to verify how many physical extents are available to the Volume Group:

    # vgdisplay VolGroup00 | grep “Free”

  11. Run the following command to extend the Logical Volume:

    # lvextend -L+#G /dev/VolGroup00/LogVol00

    Where # is the number of Free space in GB available as per the previous command. Use the full number output from Step 10 including any decimals.

    Note: To determine which logical volume to extend, use the command lvdisplay.

  12. Run the following command to expand the ext3 filesystem online, inside of the Logical Volume:

    # ext2online /dev/VolGroup00/LogVol00

    Notes:

    • Use resize2fs instead of ext2online if it is not a Red Hat virtual machine.
    • By default, Red Hat and CentOS 7 use the XFS file system you can grow the file system by running the xfs_growfs command.
  1. Run the following command to verify that the / filesystem has the new space available:

    # df -h /