ssh from anywhere

I have no trouble accessing my server inside my home from my laptop because I’m local (in the same wifi) but if I decide that I need to access my server from at a coffee shop thorough my ipaddress here is how I do it.

First make sure that ssh is install on your linux machine and you can access ssh locally.

All is need is to port forward the range 22 by accessing your router. That’s it!

Now you can
$ ssh username@ipaddress

to make sure your ssh is running
$ service ssh status
to start it if not
$ /etc/init.d/ssh start

linux, ubuntu, putty, ssh anywhere port 22 connect to host connection refused port forwarding

resource
http://forums.fedoraforum.org/showthread.php?t=259571

updated 2014-01-14

>change IP address on linux

>I was having issues with git connection to my laptop thru ssh. Then after looking into it, my laptop had changed IP address. Now I didnt want to change all the git fetch origin source on all my repositories so here is how to change the IP address back.

# sudo ifconfig [connection] [IP you want]
$ sudo ifconfig eth0 192.168.1.5

sources:
http://www.cyberciti.biz/faq/linux-change-ip-address/

>Learn how to program thru examples

>Learning how the program is like riding a bike. You cannot fully learn it without applying it. After learning various languages I noticed that not everything the languages contains is useful, at least for me at this time. I found this by building my own useful programs or dissecting one. I need examples!

I have found no use for interfaces, I have study it but i have yet to see it in a necessary program. You can learn all kinds of theories but if you dont apply it to real life situations, its a waste just like formal education, half of the crap you learn in school you never use. They teach you things that you “might” use giving you a general knowledge.

>Learn other programming languages

>The first programming language I started learning was PHP then came javascript, python and c++. What I’m amazed is how much better understanding about a language when you study other ones. In reality programming languages are the same the only difference is syntax and couple different features here and there.

You’ll enjoy learning a new language while refreshing general programming skills such as functions, loops, class, switch, if statements as so on. The other benefit is a common technique used in c++ might not be common in other languages. And now you have learned it and you can implement it into your language of choice.

OOP is quite new in PHP compared to c++. The reason PHP added this feature was because OOP made c++ very powerful and easy to maintain, and why not have the same for PHP.

>Test someone smartness

>We are in an unique time in the world that we can easily test if someone is smart or dumb. All you have to ask them who they support as a republican candidate. If they say anything other than Ron Paul their stupid. Now this is a given but you can also probe them to confirm it. Here how I did it to someone today.

Me: so you support Mitt Romney
lady: yes
Me: did you know he would sign the NDAA
lady: (no response)
Me: Do you know what the NDAA is?
Lady: no
Me: (I exampled it)
Lady: this is already happening
Me: its not a reason to support it, I support Ron Paul
Lady: yeah he appeals to young people like you
Me: he is about the constitution and what are founders believed in

(after she saw she couldn’t argue intellectually with me)
Lady: Ron Paul is too old, he doesn’t have a image of a president
Me: So to be a president you need to look like it
Lady: yes
Me: if you’re not a white male you cannot be president
Lady: (silence)
Me: we should not vote for a president just because he looks like he fits the job description but what he believes in and his past record.

This small conversation show how of an idiot this lady is. She didn’t know why she supported Mitt Romney other than he “looks” like he could be a president. Unfortunately there’s many others like her.

>The cream always rise to the top

>Don’t let the fear of not posting because what you are writing is not perceived as high quality. Quality is in the eye of the beholder. Because at the end of the day you cannot please everyone.

Of course there’s fine line between complete crap and low quality. But low quality shouldn’t give you paralysis of analysis. Some will be good some will be bad and “the cream will rise to the top” or in other words “the best comes out ahead”

Things change, motivation alters and direction redirects. If what you’re doing today changes don’t get all worried because you steered away from your original idea. Its all about getting it moving and everything will add together.

Look at Apple, initially they were called Apple Computers but later changed their name to Apple because they decided they weren’t going to only focus on computers but other technologies as well. Business and people need to learn how to adjust, become flexible and take advantage of an opportunity when it becomes available.

>Passwordless SSH login Tutorial

>$ ssh-keygen -t rsa

Generating public/private rsa key pair.
Enter file in which to save the key (/home/bigbang/.ssh/id_rsa):
(Enter)
Enter passphrase (empty for no passphrase):
(Enter)
Enter same passphrase again:
(Enter)

# this creates a file ~/.ssh/authorized_keys
$ ssh-copy-id user@192.168.1.217
user@192.168.1.217’s password:
(Enter Password)

Now test login in via ssh. It will not ask for the password

ssh without password

SimpleXML, Birds Eye View

XML is always been a pain to me. The way I learn the best is by looking at examples. Below is a script from a project that I was recently working on using php SimpleXML object. It shows an organize format of the XML file to serve as a road map

<?php
$xmlstr = <<<XML
<?xml version='1.0' standalone='yes'?>
<movies>
 <movie>
  <title>PHP: Behind the Parser</title>
  <characters>
   <character>
    <name>Ms. Coder</name>
    <actor>Onlivia Actora</actor>
   </character>
   <character>
    <name>Mr. Coder</name>
    <actor>El Act&#211;r</actor>
   </character>
  </characters>
  <plot>
   So, this language. It's like, a programming language. Or is it a
   scripting language? All is revealed in this thrilling horror spoof
   of a documentary.
  </plot>
  <great-lines>
   <line>PHP solves all my web problems</line>
  </great-lines>
  <rating type="thumbs">7</rating>
  <rating type="stars">5</rating>
 </movie>
</movies>
XML;

//Output
$xml = new SimpleXMLElement($xmlstr);

echo '<pre>';print_r($xml->movie);echo '</pre>';echo 'Example:' . $xml->movie[0]->title;

?>

Script above will output

SimpleXMLElement Object
(
    [title] => PHP: Behind the Parser
    [characters] => SimpleXMLElement Object
        (
            [character] => Array
                (
                    [0] => SimpleXMLElement Object
                        (
                            [name] => Ms. Coder
                            [actor] => Onlivia Actora
                        )

                    [1] => SimpleXMLElement Object
                        (
                            [name] => Mr. Coder
                            [actor] => El ActÓr
                        )

                )

        )

    [plot] => 
   So, this language. It's like, a programming language. Or is it a
   scripting language? All is revealed in this thrilling horror spoof
   of a documentary.

    [great-lines] => SimpleXMLElement Object
        (
            [line] => PHP solves all my web problems
        )

    [rating] => Array
        (
            [0] => 7
            [1] => 5
        )

)

Example:PHP: Behind the Parser

>PHP file_get_contents() error, openssl

>If PHP is throwing the error below its because protocols other than http is not allowed.

Warning: file_get_contents() [function.file-get-contents]: Unable to find the wrapper “https” – did you forget to enable it when you configured PHP? in …

To allow other protocols the php_openssl extension must exist and enabled.

To enable go to php.ini and uncomment it or if using WAMP go to the PHP folder, then PHP extensions and check php_openssl

Problem Solved.

>Twilio try-out and cURL error

>I was using skype and I finding it expensive. Why $30 a year for a service plus $60 for a phone number? That’s $90 dollars for an voip service a year! So I went looking for other services and found twilio. I will testing in the following days.

I was testing how to send sms messages via twilio API and ran into error. Below is how I fixed it

Error1:
undefined constant CURLOPT_USERAGENT
Solution:
check your php.ini file and uncomment the line (remove: extension=php_curl.dll
restart your apache server.
resource:
http://drupal.org/node/1044216

Error2:
SSL certificate problem, verify that the CA cert is OK
Solution:
Added the line of code

        //this is a temporary fix for 
        //Uncaught exception 'Services_Twilio_TinyHttpException' with message 'SSL certificate problem, verify that the CA cert is OK
        //this may have a security flaw
        //resources: https://github.com/twilio/twilio-php/issues/18         http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/
        $http = new Services_Twilio_TinyHttp('https://api.twilio.com', array('curlopts' => array(
                CURLOPT_SSL_VERIFYPEER => false
        )));

Resource:
https://github.com/twilio/twilio-php/issues/18