Pages

Saturday 30 June 2018

Openwrt pptp client set authentication protocols

I tried to setup VPN gateway on OpenWRT router that would connect to my VPS. I used instructions from openwrt wiki which was basically this:

opkg update
opkg install ppp-mod-pptp kmod-nf-nathelper-extra
opkg install luci-proto-ppp

Then in web interface add new network interface PPtP, create firewall zone, configure this whole thing and reboot.

But that doesn't seem to be complete. My connection could not be established due to authentication protocols. Google was hopeless here, fortunatelly pptpd documentation from Arch gave an idea how to configure it.

Failure:

Sat Jun 30 19:10:56 2018 daemon.notice netifd: Interface 'VPN' is setting up now
Sat Jun 30 19:10:57 2018 daemon.info pppd[18455]: Plugin pptp.so loaded.
Sat Jun 30 19:10:57 2018 daemon.info pppd[18455]: PPTP plugin version 1.00
Sat Jun 30 19:10:57 2018 daemon.notice pppd[18455]: pppd 2.4.7 started by root, uid 0
Sat Jun 30 19:10:57 2018 daemon.debug pppd[18456]: pptp: call manager for 185.234.216.151
Sat Jun 30 19:10:57 2018 daemon.debug pppd[18456]: window size: 50
Sat Jun 30 19:10:57 2018 daemon.debug pppd[18456]: call id:     617
Sat Jun 30 19:10:57 2018 daemon.debug pppd[18456]: control connection
Sat Jun 30 19:10:57 2018 daemon.debug pppd[18456]: unix_sock
Sat Jun 30 19:10:57 2018 daemon.debug pppd[18461]: Sent control packet type is 1 'Start-Control-Connection-Request'
Sat Jun 30 19:10:57 2018 daemon.debug pppd[18461]: Received Start Control Connection Reply
Sat Jun 30 19:10:57 2018 daemon.debug pppd[18461]: Client connection established.
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18461]: Sent control packet type is 7 'Outgoing-Call-Request'
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18461]: Received Outgoing Call Reply.
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18461]: Outgoing call established (call ID 617, peer's call ID 1771).
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: using channel 617
Sat Jun 30 19:10:58 2018 kern.info kernel: [ 1791.340662] pptp-VPN: renamed from ppp0
Sat Jun 30 19:10:58 2018 daemon.info pppd[18455]: Using interface pptp-VPN
Sat Jun 30 19:10:58 2018 daemon.notice pppd[18455]: Connect: pptp-VPN <--> pptp (185.234.216.151)
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x51881348>]
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: rcvd [LCP ConfReq id=0x0 <mru 1400> <auth eap> <magic 0x72477096> <pcomp> <accomp> <callback CBCP> <mrru 1614> <endpoint 13 17 01 c5 c8 51 2c 75 4c 47 4a 89 63 dc 8e b0 6d 02 b2 00 00 00 00>]
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: sent [LCP ConfRej id=0x0 <pcomp> <accomp> <callback CBCP> <mrru 1614>]
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x51881348>]
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: rcvd [LCP ConfReq id=0x1 <mru 1400> <auth eap> <magic 0x72477096> <endpoint 13 17 01 c5 c8 51 2c 75 4c 47 4a 89 63 dc 8e b0 6d 02 b2 00 00 00 00>]
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: sent [LCP ConfAck id=0x1 <mru 1400> <auth eap> <magic 0x72477096> <endpoint 13 17 01 c5 c8 51 2c 75 4c 47 4a 89 63 dc 8e b0 6d 02 b2 00 00 00 00>]
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: sent [LCP EchoReq id=0x0 magic=0x51881348]
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18461]: PPTP_SET_LINK_INFO received from peer_callid 617
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18461]:   send_accm is %lX, recv_accm is %lX
Sat Jun 30 19:10:58 2018 daemon.warn pppd[18461]: Non-zero Async Control Character Maps are not supported!
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: rcvd [EAP Request id=0x0 Identity <No message>]
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: sent [EAP Response id=0x0 Identity <Name "username">]
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: rcvd [LCP EchoRep id=0x0 magic=0x72477096]
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18455]: rcvd [EAP Failure id=0x0]
Sat Jun 30 19:10:59 2018 daemon.err pppd[18455]: EAP: peer reports authentication failure
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18455]: sent [LCP TermReq id=0x2 "Failed to authenticate ourselves to peer"]
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18455]: rcvd [LCP TermReq id=0x3 "rGp\37777777626\000<\37777777715t\000\000\003\37777777656"]
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18455]: sent [LCP TermAck id=0x3]
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18461]: PPTP_SET_LINK_INFO received from peer_callid 617
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18461]:   send_accm is %lX, recv_accm is %lX
Sat Jun 30 19:10:59 2018 daemon.warn pppd[18461]: Non-zero Async Control Character Maps are not supported!
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18455]: rcvd [LCP TermAck id=0x2 "Failed to authenticate ourselves to peer"]
Sat Jun 30 19:10:59 2018 daemon.notice pppd[18455]: Connection terminated.
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18461]: Closing connection (unhandled)
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18461]: Sent control packet type is 12 'Call-Clear-Request'
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18461]: Closing connection (call state)
Sat Jun 30 19:10:59 2018 daemon.info pppd[18455]: Exit.


My solution:

In file /etc/ppp/chap-secrets add credentials divided with TAB:

#USERNAME  PROVIDER  PASSWORD  IPADDRESS
username        *       password    *

Then in file /etc/ppp/options add below:

refuse-pap
refuse-eap
require-chap
require-mschap


After that the connection was established.


MS Outlook asking for Gmail password

While configuring Outlook to deal with my Gmail content I got stuck with password prompt. After doing some reserach I realized that I must set up another password for Outlook in Google Account settings.

1. First we need to go to Sign-in & security
2. I signing in to Google select App passwords.
3. From dropdown boxes pick mail and windows, then GENERATE button will activate.
4. Our new password will be shown on yellow rectangle.








Sunday 17 June 2018

Call php script from javascript

The idea is to create web interface for raspberry pi. I want to reload only certain elements of the http page and have possibility to execute linux commands. For example if I want to check CPU temperature I use vcgencmd measure_temp. I put this into php script and print complete javascript.

Below is my code: 

<?php
$result = exec ('sudo vcgencmd measure_temp'); 
$tempOnly = substr($result,5);  
?>

function rpiTemp()
{
        var example = <?php echo '"' . $tempOnly . '"'; ?>;
        alert(example);

}



In <head> block I include script with following:

<script type="text/javascript" src="http://raspberrypi/check_cpu_temp.php"></script>

And call it in <body> section with a button:

<input type="submit" value="Check CPU Temperature" onclick="rpiTemp()"/>