Tuesday, February 23, 2016

Windows Server 2012 Evaluation – convert & activate to fully licensed


Windows Server 2012 Evaluation – convert & activate to fully licensed

So I’m at the end of the trial period for Windows Server 2012, and having a bought a volume license for the Data Center edition, I need to activate it. Microsoft have taken away the ability to alter product keys through Control Panel -> System so we have to use the command line.
I’ve read a lot of articles out there on this, which generally don’t work, presenting an error when you try and process your new key using the slmgr command line tool.
First of all, you need to establish your exact currently installed version. From a elevated command prompt, run the following command:
DISM /online /Get-CurrentEdition
In amongst the blurb that appears on screen, it will tell you your current edition (in my case ServerDatacenterEval). Make a note of this – you will use in the next command with the last ‘Eval’ bit ommitted.
To find out which version you can upgrade to, run the following command:
DISM /online /Get-TargetEdition
This will show you which versions of Windows Server you are allowed to upgrade this version to.
With your license key to hand, now run following command:
DISM /online /Set-Edition:ServerDatacenter /ProductKey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX /AcceptEula
The above unboldened / italicised entries will need to be your own specific variables (remember to drop the ‘Eval’ bit for the Set-Edition). I believe, you can also use this as an opportunity to upgrade to a higher edition, for example using the /Set-Edition switch to go from Standard up to Datacenter. The /AcceptEula switch allows the system to silently accept the Microsoft license agreement.
When you run this command, your system will need to restart 1 or 2 times. Thereafter (if it doesn’t happen automatically) you will be able to activate with your newly provided key from Control Panel -> System or using the slmgr tool, and you will now be running your licensed copy :)

Monday, February 22, 2016

How To Set Up SSH Keys

How To Set Up SSH Keys


About SSH Keys

SSH keys provide a more secure way of logging into a virtual private server with SSH than using a password alone. While a password can eventually be cracked with a brute force attack, SSH keys are nearly impossible to decipher by brute force alone. Generating a key pair provides you with two long string of characters: a public and a private key. You can place the public key on any server, and then unlock it by connecting to it with a client that already has the private key. When the two match up, the system unlocks without the need for a password. You can increase security even more by protecting the private key with a passphrase.

Step One—Create the RSA Key Pair

The first step is to create the key pair on the client machine (there is a good chance that this will just be your computer):
ssh-keygen -t rsa

Step Two—Store the Keys and Passphrase

Once you have entered the Gen Key command, you will get a few more questions:
Enter file in which to save the key (/home/demo/.ssh/id_rsa):
You can press enter here, saving the file to the user home (in this case, my example user is called demo).
Enter passphrase (empty for no passphrase):
It's up to you whether you want to use a passphrase. Entering a passphrase does have its benefits: the security of a key, no matter how encrypted, still depends on the fact that it is not visible to anyone else. Should a passphrase-protected private key fall into an unauthorized users possession, they will be unable to log in to its associated accounts until they figure out the passphrase, buying the hacked user some extra time. The only downside, of course, to having a passphrase, is then having to type it in each time you use the Key Pair.
The entire key generation process looks like this:
ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/demo/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/demo/.ssh/id_rsa.
Your public key has been saved in /home/demo/.ssh/id_rsa.pub.
The key fingerprint is:
4a:dd:0a:c6:35:4e:3f:ed:27:38:8c:74:44:4d:93:67 demo@a
The key's randomart image is:
+--[ RSA 2048]----+
|          .oo.   |
|         .  o.E  |
|        + .  o   |
|     . = = .     |
|      = S = .    |
|     o + = +     |
|      . o + o .  |
|           . o   |
|                 |
+-----------------+
The public key is now located in /home/demo/.ssh/id_rsa.pub The private key (identification) is now located in /home/demo/.ssh/id_rsa

Step Three—Copy the Public Key

Once the key pair is generated, it's time to place the public key on the virtual server that we want to use.
You can copy the public key into the new machine's authorized_keys file with the ssh-copy-id command. Make sure to replace the example username and IP address below.
ssh-copy-id user@123.45.56.78
Alternatively, you can paste in the keys using SSH:
cat ~/.ssh/id_rsa.pub | ssh user@123.45.56.78 "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"
No matter which command you chose, you should see something like:
The authenticity of host '12.34.56.78 (12.34.56.78)' can't be established.
RSA key fingerprint is b1:2d:33:67:ce:35:4d:5f:f3:a8:cd:c0:c4:48:86:12.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '12.34.56.78' (RSA) to the list of known hosts.
user@12.34.56.78's password: 
Now try logging into the machine, with "ssh 'user@12.34.56.78'", and check in:

  ~/.ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.
Now you can go ahead and log into user@12.34.56.78 and you will not be prompted for a password. However, if you set a passphrase, you will be asked to enter the passphrase at that time (and whenever else you log in in the future).

Optional Step Four—Disable the Password for Root Login

Once you have copied your SSH keys unto your server and ensured that you can log in with the SSH keys alone, you can go ahead and restrict the root login to only be permitted via SSH keys.
In order to do this, open up the SSH config file:
sudo nano /etc/ssh/sshd_config
Within that file, find the line that includes PermitRootLogin and modify it to ensure that users can only connect with their SSH key:
PermitRootLogin without-password
Put the changes into effect:
reload ssh


Sunday, February 21, 2016

Mac OS X boot-time keyboard shortcuts


Mac OS X boot-time keyboard shortcuts (in no particular order):


  1. Hold down D during startup
    • Takes you to Apple's Hardware Test utility
  2. Hold down Alt+Cmd+P+R during startup
    • Clears the PRAM (parameter RAM) and NVRAM (non-volatile RAM): if either the PRAM or the NVRAM become corrupt, problems will ensue. Hold the keys down until your computer restarts: release the keys after you hear the second startup sound.
  3. Hold Alt down during startup
    • This will load the boot menu allowing you to boot to a different operating system partition you may have installed on your hard drive. May also allow you to boot to a USB, but that's just a conjecture.
  4. Hold down N during startup
    • if your setup includes a compatible network server (NetBoot), you can hold down the said key during boot to attempt a network boot. You can alternatively use the Alt+N keys during startup to start from a NetBoot server using the default boot image provided.
  5. Hold down T during startup
    • puts your Mac into Target Disk Mode, effectively turning your computer into a large removable flash drive. (Allows you to transfer files to and from your machine with...ease?)
  6. Hold down Shift during startup
    • Boot into safe mode. Very similar to Windows Safe Mode; a great way to troubleshoot OSX applications and extensions that aren't working properly.
  7. Hold down Cmd+V during startup
    • Boot into verbose mode. A terminal-like interface will appear while booting. It will contain information important to startup, allowing you to diagnose startup problems by seeing any errors that may be occurring during startup. Verbose mode exits automatically when your mac finishes booting.
  8. Hold down Cmd+S during startup
    • Boot into single user mode.
      NOTE A knowledge of bash and the command-line (in general) is recommended. Handy for advanced startup sequence troubleshooting.

Tuesday, February 2, 2016

How to restart Mac OS X networking

Command line tip: How to restart Mac OS X networking

Apple LogoIf you’re a terminal warrior like me, you’ll occasionally need to reboot the OS X network interface. There’s a quick way to do this through the command line – but first you need to know the identity of your network interface.
Run the ifconfig command in your terminal and find the interface with an IP address attached to it. On my MacBook Pro, the ethernet interface is en0 while the wireless interface is en1.  Yours may be similar.

Shutting down the network interface

Now that you’ve identified the interface, shutting it down and restarting it is a breeze. Run this command:
sudo ifconfig en0 down
And to start things back up again…
sudo ifconfig en0 up
That’s it. It’s a simple command that’s worth remembering – or bookmarking!

How to Find and Change Your MAC Address on OS X


How to Find and Change Your MAC Address on OS X

Each network card on your computer has a built-in unique MAC (Media Access Control) address that can be used to identify your computer. This is usually fine, but it is possible to change it natively in OS X.
If you are running Windows or Linux you can change your MAC address easily on those platforms as well, though we should note that this is more of an advanced topic and most people shouldn’t change their MAC addresses unless they really need to.

How to find your MAC Address

OS X provides a quick and easy way to find your MAC address. Just hold down the Option key and click the Wi-Fi icon in the menu bar:
The ‘Address’ portion with all the colons is your MAC address. This is your physical MAC address, which for most people is the address you want. However, if your address has been changed, you can check what address your computer is actually using to communicate with by firing up a Terminal and running:
ifconfig en0 | grep ether
This will output your MAC address for the hardware interface en0, which for most Macs is used for Wi-Fi. You can check which interface is used for wireless by holding down the Option key and clicking the Wi-Fi icon in the menu bar, which will quickly show you what device you are using to access the Internet:

Screenshot_6_23_15__4_48_PM

How to Change Your MAC Address

If you want to change your MAC address and have a specific one in mind, you can set it with:
sudo ifconfig en0 ether aa:bb:cc:dd:ee:ff
This will set your MAC address for en0. If you have a Mac that also has an ethernet port, you may need to use en1.

How to Get a Random MAC Address

If you’re going for privacy, randomizing your MAC address is probably the best option. This command will do it automatically:
openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//' | xargs sudo ifconfig en0 ether
This will generate and set a new MAC address for en0 every time you run it. The changes made from both these commands will be reverted when you restart, so this is not permanent. If you want, you can make a script and set it to run on startup, giving you a new one for each session.
Keep in mind that after you edit your MAC address you may have network problems, so it is a good idea to restart your Wi-Fi after changing it.