WordPress SSL

This is probably going to have a few additions to it, but let’s just start with making the site admin area force https://.

To do that, open wp-config.php and this towards the end of the file:

define(‘FORCE_SSL_ADMIN’, true);
 No need restart anything, just save and reload your admin page

Incorrect wifi password in iOS

wifi under magnifying glass

My kids are always playing in areas of the iPad or iPhone that they really shouldn’t be. Unfortunately Apple have never allowed us to have a truly restrictive setup for kids in this way.

Every now and then they muck up the wifi and have tried connecting to someone else’s wifi and then they can’t reconnect to our own as it prompts for a password (or it simply doesn’t connect). Entering the correct password greets us with the annoying “incorrect password” dialog.

You know it’s the right password, it hasn’t changed in years (that’s probably the first thing we’re doing wrong right there, but that’s a whole other bag of problems).

If you have tried entering in the password, and you’re confident the password is correct there are three things you can try, the last of which will almost always work, but I like to start with the softer options:

  1. Forget the wifi network and then try to reconnect. This one will generally work if it wasn’t prompting for a password to begin with and just not connecting.
  2. You could change the wifi password in your wifi router and try connecting to that. It IS a good idea to change it once in a while anyway. If the device then connects, you could then change it back and try connecting again.
  3. Go to:
    settings >> General >> Reset >> Reset network settings
    and clear the network settings. You’ll need to confirm this with your pin but you will lose no data. DO NOT do a factory reset, in that case YOU WILL lose data. Make sure you are only resetting the network settings and continue.  After the device restarts you should be able to login without any issues.

Good luck and I hope this has helped solve your issue

changing hostname in ubuntu

I cloned a virtual server and late realised they had the same hostname.

No problem.

  1. change the hostname in /etc/hostname:
sudo nano /etc/hostname
  1. change the hostname in /etc/hosts:

this file will contain localhost and your old hostname. eg,

127.0.0.1 localhost
127.0.1.1 <new-host-name>

edit this file to suit.

Finally, change the hostname in the current session:

This can be done one of two ways. Restart the system, or issue the following command:

sudo hostname <new-host-name>

symbolic links in linux and Ubuntu

I always seem to have a tough time getting symbolic links right and often finding myself either Googling them or running test link after test link until I nail it. Normally I follow the mantra:

command {something} {somewhere}

such as:

mount /dev/sda1 /media/mydrive

/dev/sds1 being the “something” and the /media/mydrive being the somewhere

But with symbolic links, what is the something? Is it the symbolic link? is it the target? The somewhere, is that the target or is that the symbolic link? And the man page offers no help (at least not in my interpretation of it).

I’ve realised tonight the first error I’ve been making is forgetting you should explicitly set a full path to the target object (folder or file).

I’m often creating symbolic links to directories, usually remote and so a symbolic link in my home directory fits the bill.

What’s the correct syntax?

ln -s {/path/to/folder} {linkname}

ln -s /media/usbkey ~/usbkey

ln -s /run/user/1000/gvfs/afp-volume:host=DSBOX.local,user=dav3,volume=desktop/remotedir remotedir

 

Adding additional IP Address to ethernet interface

network card

Scenario: You have several devices within your network, you’ve changed the address range for the network but you’ve forgotten to change one in particular. It’s easier to log into the device than to physically attend to it (it may be headless, it may not be in your immediate vicinity, or you’re just to lazy to get out of your chair to do it.

Q. How do you log into a network device that isn’t on your subnet?

A. You create an alias IP address for your current interface within the scope of the IP address you need to hit.

In this example we’ve moved a network from a 192.168.0.1 to 10.0.0.1.

The router has been configured, all the devices have been configured and you’re up and running but realised you forgot the file server in the garage. Your whole network is now setup on the 10.0.0.1 network, but the file server is sitting patiently waiting for you back on the 192.168.0.1 network.

Here’s how you would do it in linux (Ubuntu):

>$ ifconfig
enp6s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
 inet 10.0.0.5 netmask 255.255.255.0 broadcast 10.0.0.255
 RX packets 6406862 bytes 7485766742 (7.4 GB)
 RX errors 0 dropped 0 overruns 0 frame 0
 TX packets 3920089 bytes 1566938600 (1.5 GB)
 TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

The old server is at 192.168.0.100, our computer was at 192.168.0.77. You can use any IP address that is not the device you want to connect to, and that is still within the same subnet range.

$ ifconfig enp6s0:0 192.168.0.77 up

Confirm it worked:

enp6s0: flags=4163  mtu 1500
        inet 10.0.0.5  netmask 255.255.255.0  broadcast 10.0.0.255
        ether 11:22:dd:99:4e:ee  txqueuelen 1000  (Ethernet)
        RX packets 6413204  bytes 7488178719 (7.4 GB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3925411  bytes 1568449079 (1.5 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp6s0:0: flags=4163  mtu 1500
        inet 192.168.0.77  netmask 255.255.255.0  broadcast 192.168.0.255
        ether 11:22:dd:99:4e:ee  txqueuelen 1000  (Ethernet)

note: this won’t survive a reboot. But for most intents and purposes, this will suffice. You can log into the file server and change the IP address and jump back out.

To make it permanent we will need to edit

/etc/network/interfaces

from: https://askubuntu.com/questions/585468/how-do-i-add-an-additional-ip-address-to-an-interface-in-ubuntu-14 (modified only to match the example above)

# vi /etc/network/interfaces

Append the following to the file (This is in addition to existing information, not a replacement for it)

auto enp6s0:0
iface enp6s0:0 inet static
name Ethernet alias LAN card
address 192.168.0.77
netmask 255.255.255.0
broadcast 192.168.0.255
network 192.168.0.0

Save and close the file. Restart the network:

# /etc/init.d/networking restart

using variables on the command line

Following on from my last example of copying a SSH public key to a remote computer, this is something I need to do when setting up a new computer. Setting up private/public keys for SSH just make logging in that little bit smoother.

When you need to rerun the command, you need to load it up, edit it and resubmit it. Unfortunately (although it’s probably possible) I don’t know an easy way to bring up a previous command and edit it in-line so that I can send it again without actually sending the command again before doing so.

Instead, Load a variable into the command line and change it next time.

-- 11:03:01 -- MBP:~ madivad$ ssh minixbmc
Password:
Last login: Mon Apr 25 18:23:18 2016
minixbmc:~ madivad$ exit
logout
Connection to minixbmc closed.
-- 11:03:17 -- MBP:~ madivad$ remote=minixbmc
-- 11:03:26 -- MBP:~ madivad$  history | grep remote
  439  remote=he1000
  440  cat ~/.ssh/id_rsa.pub | ssh madivad@$remote "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
  502  remote=minixbmc
-- 11:03:34 -- MBP:~ madivad$ !440
cat ~/.ssh/id_rsa.pub | ssh madivad@$remote "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
Password:
-- 11:03:40 -- MBP:~ madivad$ ssh minixbmc
Last login: Tue Apr 26 11:03:12 2016 from mbp.fritz.box
minixbmc:~ madivad$

For example, in the above session, for simple commands, I would being the history file up, reissue line 440, then edit, then issue it again. In this situation, it would have the effect of loading the key again, and that’s not what I want to do.

  • Breaking it down, I logged into the remote machine and realised a password was needed,
  • I logged out,
  • I set the “remote” variable,
  • looked for the relevant history command (I knew it had the word “remote” on it),
  • I re-issued that line, and
  • then tested the login.
  • No password was needed, the command was a success.

This could be done with other things as well where you’re always changing one element on the line (or multiple elements, and use multiple variables).

For a more simple and silly example, let’s create a quick update and install script for ubuntu:

upstall=’htop multiwatch’
sudo apt update && sudo apt install $upstall

Instead of typing the whole line next time, I can just type the new apps to install in the “upstall” variable and reissue the command (in this case, using arrow up a couple of times, or grabbing the index from the history file).

$ sudo apt update && sudo apt install $upstall
[sudo] password for madivad:
Hit:1 http://au.archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://au.archive.ubuntu.com/ubuntu xenial-updates InRelease [92.2 kB]
Hit:3 http://au.archive.ubuntu.com/ubuntu xenial-backports InRelease
Get:4 http://security.ubuntu.com/ubuntu xenial-security InRelease [92.2 kB]
Fetched 184 kB in 1s (101 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
byobu is already the newest version (5.106-0ubuntu1).
htop is already the newest version (2.0.1-1).
multiwatch is already the newest version (1.0.0-rc1+really1.0.0-1).
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.

If I then later want do another update and install something else, I can re-set the “upstall” variable and arrow up or grab it out of history.

11:53:44 madivad@he1000:~$ upstall=jq
12:03:44 madivad@he1000:~$ sudo apt update && sudo apt install $upstall
Hit:1 http://au.archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://au.archive.ubuntu.com/ubuntu xenial-updates InRelease [92.2 kB]
Hit:3 http://au.archive.ubuntu.com/ubuntu xenial-backports InRelease
Get:4 http://security.ubuntu.com/ubuntu xenial-security InRelease [92.2 kB]
Fetched 184 kB in 2s (91.0 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
jq is already the newest version (1.5+dfsg-1).
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
I'm a simple man, I like simplicity. And although there are probably better ways to do this, for the time being, this is how I'm getting the job done. It works well for me, but I'm open to any suggestions and/or improvements.

As I said, not the best example, but hopefully you get the idea.

sudo please

I stumbled across this alias quite a few months ago, but it was under a different name then.

I wanted to find it today and Google searches brought up a whole heap of malicious finds on it, aimed at targeting the unsuspecting newbie to linux. Obviously there are some very dangerous linux commands and so I’m not going to repost them here. Or maybe.

In linux, when you need special permissions to run a command, you’ll get a “permission denied” error. The standard response to that is to “sudo !!” (pron: sudo bang bang) which runs the last command again. Everyone who’s ever used linux will know this can get frustrating.

The I found “fuckit” (or it could have been just “fuck”, I can’t remember which).

When you forget to type sudo, and you’re prompted your permission has been denied, you can issue the expletive whereby the command runs as expected. The funny thing about this, is that when this does happen, it is the sort of thing you are probably thinking, and the expletive does it’s job.

In looking for it today, I found that someone else uses the “please” alias instead. There’s no difference, they both do the same job. It’s just how you feel you want to talk (type) to your computer at the time.

To achieve this, you need to create an alias:

alias please='sudo $(fc -ln -1)'
alias fuck=please

Only include the second line if you feel so inclined. I did because initially you can be all like “please?? Oh thank you understanding computer.” but after a day of permission denied errors, you might be more inclined to just yell at the screen, in which case, the second line is more appropriate.

Creating the alias alone won’t make it persistent. To do that, add the alias to the end of your ~/.bashrc file, or in my case, I’m running ubuntu and you can add it to ~/.bash_aliases instead.

Youtube embedded videos in WordPress not working

You’ll notice above that there is a youtube URL on the first line… it hasn’t embedded within the post.

UPDATE 2015-12-10: it’s working now, is it a WordPress 4.4 thing? I have disabled a LOT of plugins for the moment, I’ll come back and revisit this in the next couple of days. I have spent many hours working on this problem over the last few months and having just found I’ve had other issues, I’ll revisit this again

Embed the URL without embed tags
Embed the URL without embed tags

Also, I have just learned today that the youtube style of embedding without embed tags have been extended in WordPress 4.4 to include URLs to your own WordPress site (and possibly others).

Are you finding your http://youtu.be/{videocode} youtube links not embedding correctly or working in WordPress?

The correct format for the link is any one of the following:

http://youtu.be/{videocode}
http://youtube.com/watch?v={videocode}
[ embed]http://youtu.be/{videocode}[/embed ]

(there is a space before the embed in the above one to have it display correctly)

There are three things to watch out for to ensure this works. And if you do each of these, then you don’t need to use the [ embed ] code you see in the third example above. They are:

  1. Ensure the URL is on it’s own line
  2. Ensure you use HTTP in lieu of HTTPS (*1)
  3. Ensure the link does NOT appear on the first DISPLAYED line of the content

*1 : this is not a big one, since it seems most of the time it works, but for some reason it didn’t when I used it on this particular occasion.

I say DISPLAYED because in an effort to fix this, I tried putting a blank line for the first line. The problem persisted. It also didn’t help to include just a full-stop (period) there either.

I do believe it could also be theme related as this theme does not use the different post type options that is present in the newer themes. And from what I did find elsewhere, selecting different options in that meta-box can alter this behaviour. I will probably be changing themes in the coming months as I work further on my own custom theme, but for the time being if I want it to appear on the first line, I will use the appropriate [ embed ] code above (with the space removed!). This was not a problem I found documented anywhere else, so hopefully you have found this useful!

WordPress media library limited to 10MB

Screenshot 2015-09-14 11.23.102
I think I’m a little over my quota!

Have you ever noticed this in your blog? It’s never been there before, but it appeared in the last day or two. At the time I wasn’t sure how or why. It’s my blog hosted on one of my web hosting accounts, and I have no shortage of space. So why was I getting this warning?

Screenshot 2015-09-14 11.35.24Worse yet, I went to add a photo, and this happened. That’s when I realised the quota was real!

My first question is, what dickhead gave me such a quota!

My first action was to work out where it was imposed.

Then I found who the right royal dick was. It was yours truly!

I’ve been doing too much playing in the back end and I at some point, and for some unknown reason, have turned it on.

I’m running WordPress Multisite and it’s a setting hidden in the Network Settings.

To navigate to it, click on My Sites in the top left corner, and select Network Admin. Then from the next menu select Settings.

secret hiding place for the 10MB upload quota
this little setting on the right… Make sure you turn it off! :)

And that’s it! Once, you clear that little baby, you’ll be able to upload to your little hearts content.

UPDATE: It looks like I wasn’t the only one who’s ever done this! 

WordPress MultiSite & sunrise.php

Are you getting the above error message as well?

After doing a fresh install and enabling multi-sites I couldn’t see the Domain Mapping and Domains sub-menu options under Network Admin / Settings.

I loaded up my trusty editor and confirmed

define('SUNRISE', 'on' );

was in fact in the file. It was slightly higher than where it said, it’s not important, but I moved it anyway, and I still got the error.

I checked and sunrise.php was in fact in the correct location under /home/public_html/wp-content/sunrise.php

So how did I fix it?

The problem was, it was the incorrect (read:old??) sunrise.php file!

Copy the correct one from:

/home/public_html/wp-content/plugins/wordpress-mu-domain-mapping/sunrise.php

and replace the previous one, and reload your admin page. You will now see the welcoming domains page :D

If you want to find out more as to why it happened, and how it is that my sunrise.php got “moved” or “re-moved”, it was due to a conflict by domain mapping plugins. I’ll be blogged about it in the near future and it will appear here (currently in draft and not published).