Posts

Vagrant in a Mixed Development Environment

On some projects we have a mixture of OSX and Windows development machines. Normally, this isn’t a problem because we develop inside a VM so we don’t need to worry about inconstancies between our development environments and production. The issue is that OSX machines do much better if you’re using nfs instead of the virtualbox provider. Unfortunately, Windows doesn’t support NFS natively so we need to have some way to determine if the machine is running on an OSX host.

Read More

Maximizing Your Efficiency in Sublime Text - Tab to Autocomplete

One of the great things about Sublime Text is that it’s intelligent enough to look at the file you’ve opened and provide context sensitive.

Read More

Fixing 'SSH Error: Host key verification failed.' error in Ansible

The other day I rebuilt a VM that we’re managing using Ansible and when we tried to have Ansible reset it’s configuration we received the following error:

fatal: [xxx.xxx.xxx.xxx] => SSH Error: Host key verification failed.
    while connecting to xxx.xxx.xxx.xxx:22
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.

Ansible doesn’t provide a good explanation of how to fix this but the issue resolves around the fact that the IP address stayed the same but when the server was rebuilt the SSH keys changed and there’s a conflict in the known_hosts file.

If you attempt to SSH into the box as that user SSH will help you fix the problem:

user@host:~/path$ ssh user@xxx.xxx.xxx.xxx
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
a0:c9:23:12:f4:91:91:f0:45:0e:6c:d3:2e:ae:63:d7.
Please contact your system administrator.
Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/user/.ssh/known_hosts:13
  remove with: ssh-keygen -f "/home/user/.ssh/known_hosts" -R xxx.xxx.xxx.xxx
ECDSA host key for xxx.xxx.xxx.xxx has changed and you have requested strict checking.
Host key verification failed.

Then running the ssh-keygen command removes the bad entry:

user@host:~/path$ ssh-keygen -f "/home/user/.ssh/known_hosts" -R xxx.xxx.xxx.xxx
# Host xxx.xxx.xxx.xxx found: line 13 type ECDSA
/home/user/.ssh/known_hosts updated.
Original contents retained as /home/user/.ssh/known_hosts.old

And finally we can now run Ansible and it will connect!

user@host:~/path$ ansible-playbook -v --inventory-file=ansible/inventory/production.ini -u user ansible/devel.yml

PLAY [all] ********************************************************************

GATHERING FACTS ***************************************************************
The authenticity of host 'xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx)' can't be established.
ECDSA key fingerprint is a0:c9:23:12:f4:91:91:f0:45:0e:6c:d3:2e:ae:63:d7.
Are you sure you want to continue connecting (yes/no)? yes

Link Post and Podcast Roundup: August 2016 Edition

More links for your enjoyment.

Read More

Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error

I received an interesting error a couple days ago when I tried to push to GitHub:

remote: error: File dumpfile.sql is 118.57 MB; this exceeds GitHub's file size limit of 100 MB

It turns out that I accidentally committed a MySQL dump file that I grabbed from our development server. GitHub only allows for 100 MB file which is totally understandable but now I'm stuck with a 118 MB file in my repo with no way to push it to GitHub. It turns out with some command line fu you can remove a file completely from a repo:

git filter-branch --index-filter 'git rm --cached --ignore-unmatch dumpfile.sql' merge-point..HEAD

At which point you can push the file to GitHub.

Update 2017-07-29

So I added a new file to a repo today and it turns out GitHub changed from 100 MB to 50 MB. I've updated the title and included this so hopefully people will find it.

remote: warning: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: warning: See http://git.io/iEPt8g for more information.
remote: warning: File initial.sql.gz is 98.65 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB

Maximizing Your Efficiency in Sublime Text - User Settings

The user settings are a powerful tool for overriding some of Sublime’s default settings with ones that make it easier for you to work.

Read More

Finding Merge Changes Without Whitespace Changes in GitHub

When we’re on boarding new programmers we always institute a code review process where at least one programmer experienced with the project reviews the work of the new programmer. We use GitHub’s Pull Request feature to help us do this. Most of the changes are easy for us to review and then approve or tell the programmer they need to make changes. Every so often we run into a file where GitHub lets us down (really I don’t know what else they would do here :-)):

merge with 8k+ changes

The issue was that this particular file had it’s line endings changes on the master branch but not the pull request branch it was messing up the whole system. To try and make sense of all the changes we had to resort to using the command line:

git diff "pr/#" master -w -- file\path\here > temp.txt

This command is calculating the differences in the file (“file\path\here”) between the pull request branch (“pr/#”) and the master branch but it’s ignore all whitespace when comparing the two (“-w”).

This produced a much shorter (20 lines) list of changes which we then had to manually merge in but at least the programmer didn’t loose all their work.

Help Support This Programming Thing!

This Programming Thing is a labor of love but it costs money to host the site. If you would like to help us offset some of our costs and you need a virtual server from DigitalOcean please use the link below.

www.digitalocean.com/?refcode=4f051fe2bd21

Maximizing Your Efficiency in Sublime Text - Right Click

I know what you’re thinking. How can right clicking make me more efficient in Sublime Text.

Read More

Maximizing Your Efficiency in Sublime Text - Intro

As knowledge workers, there’s a huge benefit to us knowing how to do things are quickly as possible in our environments of choice. It doesn’t mater if that’s an IDE or Excel every second saved can really add up.

Chart Showing how small actions can add up to lots of time.

I use Sublime Text every day at work and some days when I’m not working (today I’m off work but I’m working on this post using Sublime Text) so I thought it would be a good place to start. The goal is to release short posts every week so instead of having to digest a HUGE article with tips you can learn a few and them apply those to your daily work. Some of my examples will be geared towards PHP developers specifically but I think most will be applicable to anyone using Sublime Text.

If you feel like I’ve forgotten something or want something added please feel free to leave a comment on this page and we’ll add it.

RSS

Join Our Mailing List!

View previous campaigns.

Top Posts

  1. Working With Soft Deletes in Laravel (By Example)
  2. Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
  3. Upgrading to Laravel 8.x
  4. Get The Count of the Number of Users in an AD Group
  5. Multiple Vagrant VMs in One Vagrantfile
  6. Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
  7. Changing the Directory Vagrant Stores the VMs In
  8. Accepting Android SDK Licenses From The OSX Command Line
  9. Fixing the 'Target class [config] does not exist' Error
  10. Using Rectangle to Manage MacOS Windows

subscribe via RSS

All content copyright This Programming Thing 2012 - 2021
Blogging about PHP, MySQL, Zend Framework, MySQL, Server Administration and Programming in general