How to Login to your AWS EC2 without a .pem Key

Essentially there is always a few steps to follow in order to easy SSH in to your AWS server without the need for your .pem key. For security reasons, this is not an option when you first setup a server, but with these few instructions, right when you setup your server can save you a lot of irritation always hunting down the correct .pem key.

Pre-Requisites

  • Must have an AWS Account
  • Must have a way to use commands line. (PuTTY is an option for windows)
  • EC2 Server (Click here you need help launching a EC2 on Amazon

Part 1: Generate a id_rsa.pub

Generate a id_rsa.pub if you have not done so already. Here are the steps needed for that.

  1. We need to navigate where we typically keep our system ssh key, in command line:
    $ cd ~/.ssh
  2. Next, we will generate a key with our email address.
    $ ssh-keygen -t rsa -C "your_email@example.com"

    It will ask you a few questions, you can just hit “Enter”.

  3. Then type
    $ ls -l

    This will list out all of the files, it will look something like this:cli ls image

  4. Next we need to copy our .pub key to our clipboard so we can post it in Github. Run:
    $ pbcopy < id_rsa.pub 

You can find more details if needed about id_rsa.pub here.

Part 2: Login to your EC2 Server and Add your Key

We are going to SSH into our current server and then add our key to your server so we do not have to use .pem any more to login.

  1. First lets, login to our AWS console.
  2. Next, we will select EC2 and then click on instances. With your instance selected, click on one of the servers and hit connect. It will launch a dialog box with your connection string in there. It should look something like this:
    amazon dialog box
  3. Now grab your connection string and goto command line and past it in. Ex:
    $ ssh -i erickey.pem ubuntu@54.215.171.225
  4. Once you're connected to your server, you will need so login into the root user. You will be able to do this by using:
    $ sudo su
  5. Next we will cd into our directory with our authorized_keys to add th id_rsa.pub that we have copied to our clipboard. Run:
    $ cd ~/.ssh

    Here you will see a file called authorized_keys

  6. We need to modify this file by adding our key. Run:
    $ nano authorized_keys

    and paste your key into the file under the default key at the top. To exit out of the file, hit ctrl+x and then hit y to save the file.

Final

Now you will be able to exit your server and log back in as root just by using

$ ssh root@xxx.xxx.xxx.xx

This makes life a lot easier, so you don't have to hunt down that pesky .pem file and where you put it.

Make a Script Executable from Anywhere

Three easy steps can be used.

1) Create Script

2) chmod +x  myscript

3) cp myscript /user/local/bin

B … b.. b… that’s All folks

This is something that I forget often, but comes very useful when needed.

Why every company needs a full-time web developer!

Every software company I have been to seems to have one consistent problem amongst them. “The Website” the main kitten-kaboodle. The main spot for a company to say whatever they may want, and in less than one second convince someone to stay on the page and read more or click away. In other words, the make or break.

PROBLEM

A lot of companies start with their website development in the engineering department and I would say there is nothing wrong with this because it’s the job of the engineering department to setup a structure and allocate work cycles and maybe even a JIRA project for issues to be submitted.

WAIT… Did we just turn our company website into an engineering project with release cycles and I have to write an issue and have it prioritized with product based or application based bugs. YOU mean I have to write a Jira ticket to get an image changed?? WTF.!! This is where all hell breaks loose. The marketing wants a press release to go up immediately, the CEO wants an image change done, and the product management department needs all links on the website that link to documentation changed.

All of these little things equal to one thing = “A WEB DEVELOPER”. I think most people think of their websites as a static block that they will develop and never touch, and sometimes that’s true, but very very rare. Most likely, clients will want their website to evolve like their business is, updated products or services would require website changes, maybe move to a new office, website change. So many things that would require you to reach out to your contractor or request engineering to do, but neither of those is essentially ideal.

WHY?

Examples of the different scenarios are listed for the different owners of the website. Engineering Owner: Well, if it’s engineering, most likely it won’t take precedence over a product enhancement or feature that they might be working on. Contract Owner: You write an email or call your contractor and hope that you will get a quick response, but this contractor might have other work or be too busy to make quick changes. So once again, you’re shit out of luck. Marketing Owner: The change you want might be too technical, so the marketing person will have to talk to someone in Engineering to get it done and thus now you are using two resources to get one simple task accomplished.

SOLUTION

A web developer.  Someone that does cross-functional team work, between engineering, marketing, design. They have a good grasp of front-end technologies such as HTML, CSS, JS, PHP, NODE, Ruby, and CMS systems and how an infrastructure can empower a business, not cripple it.  This person will need to keep up with the latest web trends.

Web Trends A passionate web developer typically follows along with web trends which can change the way people generally interact with a website and even lend an edge if you follow a new trend that has shown promise for consumability of your content.

Communication becomes the second main job of this person after knowing their craft, because when working in a cross-team job role. It becomes crucial.

Marketing
Understanding what marketing needs to release and when they need to release it, if it needs certain trackability, or functionality for the Marketing Automation system or CRM.

Design
Some organizations have design without marketing but not all, and the best web developers typically have enough design experience to output something great, but having a designer can definitely help take it up a notch. This relationship between the web developer and designer must be tight. Talking about sharing dessert tight.

Engineering
Having a relationship to understand the backend technologies for storing data and cross communicating between user interactions and data storage. Communication must be clear for best functionality of the website.

FINAL THOUGHTS

Hire a devoted web developer to save you from pulling your hair out and several hours of sleep. If you’re worried about the web developer not having anything to do because the website is in good order. DON’T! This is when the web developer can contribute to the engineering team and be creative to make improvements. A good web developer is always looking for ways to improve their work for the benefit of a user/visitor to understand your company’s message. Til next time, Kudos.

WordPress without FTP – Plugin Install & Update Fix

Run this command once you are logged in through terminal.

sudo chown -R www-data:www-data (your wordpress folder)

This is for a Linux ubuntu host running Apache.
This will fix the FTP request that wordpress gives you if you try to install a plugin or update through the admin portal.

Many people who use WordPress have a hosting provider that offers FTP, which makes it easy on several levels for file permissions, but not everyone uses this. Some people use AWS such as myself and ‘ssh’ into their servers to perform certain actions.

WordPress wasn’t made to be super friendly for this type of setup, so making sure you have all the right permissions can be crucial in saving you several hours. I recommend learning about different permissions for wordpress from their reference page: http://codex.wordpress.org/Changing_File_Permissions

Permalinks in WordPress can drive you crazy

Start typing “Permalinks” into Google and you will quickly start seeing links that are relative to WordPress.

The most popular links for permalink help are noted here:

What these wordpress pages don’t say

An exact checklist for checking why your permalinks might not be working.

Pre-requisites: Check Setup –  Linux + Apache + MySQL + PHP

  1. Check to see if default permalinks work.

    If:
    YES – Continue to next step
    NO – Continue to step 4

  2. Check your DB (Especially if you have moved or transferred your website from another domain.)

  3. Check your .htaccess file in the root of the wordpress directory.

    How:
    White in your root directory, type:

    nano .htaccess

    Screen Shot 2014-04-29 at 2.46.07 AM

  4. Check your server configuration file.

    How: While in your root directory after you SSH through into server, type:

    cd /etc/apache2/sites-available

    – You should see a file with your website name.
    Screen Shot 2014-04-29 at 2.51.06 AMThen type nano {file name}. For me it would be

    nano smartass

    You should then see this screen.
    Screen Shot 2014-04-27 at 8.32.45 PM

  5. Check your file permissions

    How: White in the directory of the file or folder you want to check permissions on, type ls -ld {dir/file name}, for me:

     ls -ld smartass

    Screen Shot 2014-04-27 at 8.34.11 PM

  6. Check that your mod_rewrite module is enabled.

A lot of times you will go through the links when you search and end up going in circles between your WordPress install and backend, crossing your fingers that your permalinks will finally work.  Several resources can be found in a search, but I couldn’t find a defined checklist, so I made this and hope that it can help someone and save them time.

In writing this, I will admit to my mistake or going through several different sites and spending up to 3 hours trying to figure out which problem it was, before finding a short post about enabling the mod_rewrite on the server. And for me, the mod_rewrite being disabled was not allowing the .htaccess file to work properly and thus breaking the permalinks. You can laugh at me because for me, I completely felt like:

Womp womp…. 3 hours wasted on a small thing that should have been standard. Now listed as Step 6.

Lesson learned:

Never assume the default setup has everything you need for your server and WordPress.