SlideShare a Scribd company logo
1 of 17
Download to read offline
Service Intergration 
Jang Jaemin 
jaeminj@gmail.com
Openssh + authentication key(1) 
fabio@morpheus:~$ ssh-keygen 
Generating public/private rsa key pair. 
Enter file in which to save the key (/home/fabio/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/fabio/.ssh/id_rsa. 
Your public key has been saved in /home/fabio/.ssh/id_rsa.pub. 
The key fingerprint is: 
44:3e:ef:58:94:15:52:c2:88:ca:ab:21:43:53:3d:42 fabio@morpheus 
fabio@morpheus:~$ 
fabio@morpheus:~$ ssh-keygen -p 
Enter file in which the key is (/home/fabio/.ssh/id_rsa): 
Key has comment '/home/fabio/.ssh/id_rsa' 
Enter new passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved with the new passphrase. 
fabio@morpheus:~$
Openssh + authentication key(2) 
Install the public key on the servers 
fabio@morpheus:~$ ssh-copy-id -i .ssh/id_rsa.pub ornellas@apanela.com 
15 
ornellas@apanela.com's password: 
Now try logging into the machine, with "ssh 'ornellas@apanela.com'", and check in: 
.ssh/authorized_keys 
to make sure we haven't added extra keys that you weren't expecting. 
fabio@morpheus:~$
freesshd(1) 
Overview 
Install and configure FreeSSHd on the server 
Create keys 
configure Putty to connect to the server 
Install FreeSSHd 
Download FreeSSHd from http://www.freesshd.com/?ctt=download 
Double click to start installer on the server 
As a service 
Accept all other defaults
freesshd(2) 
Configure FreeSSHd 
Open FreeSSHd settings (may have to kill the service and start manually to get the GUI) 
SSH tab: 
Max number = 2 
idle = 600 
Authentication tab 
Pub key folder = C:Program Files (x86)freeSSHdkeys 
Password auth = disabled 
Pub key auth = required 
Users tab 
add 
login=chef 
auth = 'Pub key (ssh only)' 
user can use = shell 
click OK
freesshd(3) 
Generate Public and Private keys 
Open PuttyGen 
Click โ€˜Generateโ€™ 
move the mouse pointer around as instructed to generate the key 
Save a Putty compatible private key 
Click โ€˜Save private keyโ€™ 
Save this to the client PC, Putty will need this 
You should really save with a passphrase for extra security 
Save OpenSSL compatible private key for Chef knife 
โ€˜Conversionsโ€™ menu > โ€˜Export OpenSSH Keyโ€™ > save as a *.pem 
Save the public key 
Copy the contents of โ€˜Public key for pasting into OpenSSH authorized file:โ€™ and paste into a textfile. 
rename this file โ€˜chefโ€™ (no file extension, the filename must match the user login name created drop this file into the public key folder C:Program Files (x86)freeSSHdkeys on the server.
freesshd(4) 
Connecting with Putty 
Open Putty (or Putty portable) 
Enter the IP address of the server 
Connection type = SSH (obviously!) 
In the left menu tree 
Connection > SSH > Auth > โ€˜Private key file for authentication:โ€™ > click browse 
Select the private key that was generated above 
Click โ€˜Openโ€™ 
when prompted โ€˜login:โ€™ > enter โ€˜chefโ€™ > hit enter 
If the private key was saved with a passphrase then enter this when prompted 
You should now be connected to the server. 
ssh -o ConnectTimeOut=10 -o Port='22' -o IdentityFile=key/'id_rsa'  
-o GSSAPIAuthentication=no -o PasswordAuthentication=no  
-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null  
-o LogLevel=ERROR 'XXX'@'192.168.XXX.XXX'
Sshclient.php 
<? 
$this->cli= parent::newClass("sshclient", $ssh_conf); 
$this->cli->exec( $cmd); 
$data['stdout'] = $this->stdout ; 
$data['stderr'] = $this->stderr; 
?>
JSON, Rest Api , bash, PHP, 
Powershell
Json (Javascript Object Notation) 
{ 
"glossary": { 
"title": "example glossary", 
"GlossDiv": { 
"title": "S", 
"GlossList": { 
"GlossEntry": { 
"ID": "SGML", 
"SortAs": "SGML", 
"GlossTerm": "Standard Generalized Markup Language", 
"Acronym": "SGML", 
"Abbrev": "ISO 8879:1986", 
"GlossDef": { 
"para": "A meta-markup language, used to create markup languages such as DocBook.", 
"GlossSeeAlso": ["GML", "XML"] 
}, 
"GlossSee": "markup" 
} 
} 
} 
} 
}
Restful api 
HTTP Method URI Action 
GET http://[hostname]/todo/api/v1.0/tasks 
Retrieve list of 
tasks 
GET 
http://[hostname]/todo/api/v1.0/tasks/ 
[task_id] 
Retrieve a task 
POST http://[hostname]/todo/api/v1.0/tasks 
Create a new 
task 
PUT 
http://[hostname]/todo/api/v1.0/tasks/ 
[task_id] 
Update an 
existing task 
DELETE 
http://[hostname]/todo/api/v1.0/tasks/ 
[task_id] 
Delete a task
PHP Server Side (1) 
<?php 
switch ($_SERVER['REQUEST_METHOD'] ) { 
case 'PUT': 
case 'POST': 
case 'GET': 
case 'HEAD': 
case 'DELETE': 
case 'OPTIONS': 
break; 
default: 
break; 
} 
?> 
.htaccess 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-s 
RewriteRule ^(.*)$ api.php?rquest=$1 [QSA,NC,L] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^(.*)$ api.php [QSA,NC,L] 
RewriteCond %{REQUEST_FILENAME} -s 
RewriteRule ^(.*)$ api.php [QSA,NC,L] 
</IfModule>
PHP Server Side (2) 
<?php 
$request = file_get_contents('php://input'); 
// return associative array of JSON 
$input = json_decode($request, true); 
$input['request'] = $request; 
$input['rx_datetime'] = date('Y-m-d H:i:s') ; 
header("Content-type: application/json"); 
echo json_encode($input); 
?>
Bash 
curl -i -X POST -H "Content-Type: application/json ; charset=UTF-8"  
-d '{"username":"xyz","password":"xyz"}' http://localhost:3000/api/login 
curl -i -d @credentials.json -H "Content-Type: application/json"  
http://localhost:3000/api/login 
-X [PUT | POST | GET | DELETE] 
http://blogs.plexibus.com/2010/04/12/rest-esting-with-curl-file-handling/
PHP 
<? 
$data = array("name" => "Hagrid", "age" => "36"); 
$data_string = json_encode($data); 
$ch = curl_init('http://api.local/rest/users'); 
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 
'Content-Type: application/json', 
'Content-Length: ' . strlen($data_string)) 
); 
$result = curl_exec($ch, true); 
curl_Close($ch) 
$data = json_decode($result, true) ; 
print_r($data) 
?>
Powershell Client(1) 
http://www.powershellcookbook.com/recipe/Vlhv/interact-with-rest-based-web-apis 
Invoke-RestMethod cmdlet 
PS > $url = "https://api.stackexchange.com/2.0/questions/unanswered" + 
"?order=desc&sort=activity&tagged=powershell&pagesize=10&site=stackoverflow" 
PS > $result = Invoke-RestMethod $url 
PS > $result.Items | Foreach-Object { $_.Title; $_.Link; "" } 
PS> $contact = @{ 
first_name="Jack"; 
last_name="Smith"; 
emails=@{preferred="jsmith@contoso.com";business="Jack.Smith@contoso.com"} 
} | ConvertTo-Json 
PS> Invoke-RestMethod -Uri "$ApiUri/me/contacts?access_token=$AccessToken" 
-Method Post -ContentType "application/json" -Body $contact
Powershell Client(2) 
$url = "http://www.seismi.org/api/eqs" 
$request = [System.Net.WebRequest]::Create($url) 
$request.Method="Get" 
$response = $request.GetResponse() 
$requestStream = $response.GetResponseStream() 
$readStream = New-Object System.IO.StreamReader $requestStream 
$data=$readStream.ReadToEnd() 
if($response.ContentType -match "application/xml") { 
$results = [xml]$data 
} elseif($response.ContentType -match "application/json") { 
$results = $data | ConvertFrom-Json 
} else { 
try { 
$results = [xml]$data 
} catch { 
$results = $data | ConvertFrom-Json 
} 
} 
$results

More Related Content

What's hot

preventing sqli and xss by ravi rajput in owasp meet ahmedabad
preventing sqli and xss by ravi rajput in owasp meet ahmedabadpreventing sqli and xss by ravi rajput in owasp meet ahmedabad
preventing sqli and xss by ravi rajput in owasp meet ahmedabadRavi Rajput
ย 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of SmartmatchAndrew Shitov
ย 
ZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 VersionZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 VersionIan Barber
ย 
Creating a keystroke logger in unix shell scripting
Creating a keystroke logger in unix shell scriptingCreating a keystroke logger in unix shell scripting
Creating a keystroke logger in unix shell scriptingDan Morrill
ย 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The AnswerIan Barber
ย 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 WorldFabien Potencier
ย 
Php functions
Php functionsPhp functions
Php functionsJIGAR MAKHIJA
ย 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
ย 
Perl6 grammars
Perl6 grammarsPerl6 grammars
Perl6 grammarsAndrew Shitov
ย 
ZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made SimpleZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made SimpleIan Barber
ย 
Not Really PHP by the book
Not Really PHP by the bookNot Really PHP by the book
Not Really PHP by the bookRyan Kilfedder
ย 
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]Eleanor McHugh
ย 
Redis for your boss
Redis for your bossRedis for your boss
Redis for your bossElena Kolevska
ย 
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020Andrew Lavers
ย 
On secure application of PHP wrappers
On secure application  of PHP wrappersOn secure application  of PHP wrappers
On secure application of PHP wrappersPositive Hack Days
ย 
Redis for your boss 2.0
Redis for your boss 2.0Redis for your boss 2.0
Redis for your boss 2.0Elena Kolevska
ย 
Redis for the Everyday Developer
Redis for the Everyday DeveloperRedis for the Everyday Developer
Redis for the Everyday DeveloperRoss Tuck
ย 
Whispered secrets
Whispered secretsWhispered secrets
Whispered secretsEleanor McHugh
ย 
User registration and login using stored procedure in php
User registration and login using stored procedure in phpUser registration and login using stored procedure in php
User registration and login using stored procedure in phpPHPGurukul Blog
ย 
็ฅžใซ่ฟ‘ใฅใx/net/context (Finding God with x/net/context)
็ฅžใซ่ฟ‘ใฅใx/net/context (Finding God with x/net/context)็ฅžใซ่ฟ‘ใฅใx/net/context (Finding God with x/net/context)
็ฅžใซ่ฟ‘ใฅใx/net/context (Finding God with x/net/context)guregu
ย 

What's hot (20)

preventing sqli and xss by ravi rajput in owasp meet ahmedabad
preventing sqli and xss by ravi rajput in owasp meet ahmedabadpreventing sqli and xss by ravi rajput in owasp meet ahmedabad
preventing sqli and xss by ravi rajput in owasp meet ahmedabad
ย 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of Smartmatch
ย 
ZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 VersionZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 Version
ย 
Creating a keystroke logger in unix shell scripting
Creating a keystroke logger in unix shell scriptingCreating a keystroke logger in unix shell scripting
Creating a keystroke logger in unix shell scripting
ย 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The Answer
ย 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 World
ย 
Php functions
Php functionsPhp functions
Php functions
ย 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
ย 
Perl6 grammars
Perl6 grammarsPerl6 grammars
Perl6 grammars
ย 
ZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made SimpleZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made Simple
ย 
Not Really PHP by the book
Not Really PHP by the bookNot Really PHP by the book
Not Really PHP by the book
ย 
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
ย 
Redis for your boss
Redis for your bossRedis for your boss
Redis for your boss
ย 
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
ย 
On secure application of PHP wrappers
On secure application  of PHP wrappersOn secure application  of PHP wrappers
On secure application of PHP wrappers
ย 
Redis for your boss 2.0
Redis for your boss 2.0Redis for your boss 2.0
Redis for your boss 2.0
ย 
Redis for the Everyday Developer
Redis for the Everyday DeveloperRedis for the Everyday Developer
Redis for the Everyday Developer
ย 
Whispered secrets
Whispered secretsWhispered secrets
Whispered secrets
ย 
User registration and login using stored procedure in php
User registration and login using stored procedure in phpUser registration and login using stored procedure in php
User registration and login using stored procedure in php
ย 
็ฅžใซ่ฟ‘ใฅใx/net/context (Finding God with x/net/context)
็ฅžใซ่ฟ‘ใฅใx/net/context (Finding God with x/net/context)็ฅžใซ่ฟ‘ใฅใx/net/context (Finding God with x/net/context)
็ฅžใซ่ฟ‘ใฅใx/net/context (Finding God with x/net/context)
ย 

Viewers also liked

Wireless Feature Update
Wireless Feature UpdateWireless Feature Update
Wireless Feature UpdateCisco Canada
ย 
Enterprise Network Design and Deployment
Enterprise Network Design and Deployment Enterprise Network Design and Deployment
Enterprise Network Design and Deployment Sandeep Yadav
ย 
Overview of web services
Overview of web servicesOverview of web services
Overview of web servicesPeople Strategists
ย 
Introduction to Patterns in WebSphere Message Broker
Introduction to Patterns in WebSphere Message BrokerIntroduction to Patterns in WebSphere Message Broker
Introduction to Patterns in WebSphere Message BrokerAnt Phillips
ย 
WebSphere Message Broker Training | IBM WebSphere Message Broker Online Training
WebSphere Message Broker Training | IBM WebSphere Message Broker Online TrainingWebSphere Message Broker Training | IBM WebSphere Message Broker Online Training
WebSphere Message Broker Training | IBM WebSphere Message Broker Online Trainingecorptraining2
ย 
WebSphere Message Broker installation guide
WebSphere Message Broker installation guideWebSphere Message Broker installation guide
WebSphere Message Broker installation guideVijaya Raghava Vuligundam
ย 
WebSphere Message Broker Training Agenda
WebSphere Message Broker Training AgendaWebSphere Message Broker Training Agenda
WebSphere Message Broker Training AgendaVijaya Raghava Vuligundam
ย 
Ibm message broker basic
Ibm message broker basicIbm message broker basic
Ibm message broker basicJuan Camilo Parra
ย 
WebSphere Message Broker Application Development Training
WebSphere Message Broker Application Development TrainingWebSphere Message Broker Application Development Training
WebSphere Message Broker Application Development TrainingVijaya Raghava Vuligundam
ย 
Introduction to WebSphere Message Broker
Introduction to WebSphere Message BrokerIntroduction to WebSphere Message Broker
Introduction to WebSphere Message BrokerAnt Phillips
ย 

Viewers also liked (10)

Wireless Feature Update
Wireless Feature UpdateWireless Feature Update
Wireless Feature Update
ย 
Enterprise Network Design and Deployment
Enterprise Network Design and Deployment Enterprise Network Design and Deployment
Enterprise Network Design and Deployment
ย 
Overview of web services
Overview of web servicesOverview of web services
Overview of web services
ย 
Introduction to Patterns in WebSphere Message Broker
Introduction to Patterns in WebSphere Message BrokerIntroduction to Patterns in WebSphere Message Broker
Introduction to Patterns in WebSphere Message Broker
ย 
WebSphere Message Broker Training | IBM WebSphere Message Broker Online Training
WebSphere Message Broker Training | IBM WebSphere Message Broker Online TrainingWebSphere Message Broker Training | IBM WebSphere Message Broker Online Training
WebSphere Message Broker Training | IBM WebSphere Message Broker Online Training
ย 
WebSphere Message Broker installation guide
WebSphere Message Broker installation guideWebSphere Message Broker installation guide
WebSphere Message Broker installation guide
ย 
WebSphere Message Broker Training Agenda
WebSphere Message Broker Training AgendaWebSphere Message Broker Training Agenda
WebSphere Message Broker Training Agenda
ย 
Ibm message broker basic
Ibm message broker basicIbm message broker basic
Ibm message broker basic
ย 
WebSphere Message Broker Application Development Training
WebSphere Message Broker Application Development TrainingWebSphere Message Broker Application Development Training
WebSphere Message Broker Application Development Training
ย 
Introduction to WebSphere Message Broker
Introduction to WebSphere Message BrokerIntroduction to WebSphere Message Broker
Introduction to WebSphere Message Broker
ย 

Similar to Service intergration

PHP SA 2014 - Releasing Your Open Source Project
PHP SA 2014 - Releasing Your Open Source ProjectPHP SA 2014 - Releasing Your Open Source Project
PHP SA 2014 - Releasing Your Open Source Projectxsist10
ย 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011Yusuke Wada
ย 
Php Security
Php SecurityPhp Security
Php Securityguest7cf35c
ย 
Introduction to devsecdotio
Introduction to devsecdotioIntroduction to devsecdotio
Introduction to devsecdotioBram Vogelaar
ย 
Building Modern and Secure PHP Applications โ€“ Codementor Office Hours with Be...
Building Modern and Secure PHP Applications โ€“ Codementor Office Hours with Be...Building Modern and Secure PHP Applications โ€“ Codementor Office Hours with Be...
Building Modern and Secure PHP Applications โ€“ Codementor Office Hours with Be...Arc & Codementor
ย 
Hacking with hhvm
Hacking with hhvmHacking with hhvm
Hacking with hhvmElizabeth Smith
ย 
Nko workshop - node js crud & deploy
Nko workshop - node js crud & deployNko workshop - node js crud & deploy
Nko workshop - node js crud & deploySimon Su
ย 
How to send files to remote server via ssh in php
How to send files to remote server via ssh in phpHow to send files to remote server via ssh in php
How to send files to remote server via ssh in phpAndolasoft Inc
ย 
Legacy applications - 4Developes konferencja, Piotr Pasich
Legacy applications  - 4Developes konferencja, Piotr PasichLegacy applications  - 4Developes konferencja, Piotr Pasich
Legacy applications - 4Developes konferencja, Piotr PasichPiotr Pasich
ย 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESIsmail Mukiibi
ย 
PHP Backdoor: The rise of the vuln
PHP Backdoor: The rise of the vulnPHP Backdoor: The rise of the vuln
PHP Backdoor: The rise of the vulnSandro Zaccarini
ย 
Tomรกลก ฤŒorej - OpenSSH
Tomรกลก ฤŒorej - OpenSSHTomรกลก ฤŒorej - OpenSSH
Tomรกลก ฤŒorej - OpenSSHwebelement
ย 
PHP and Databases
PHP and DatabasesPHP and Databases
PHP and DatabasesThings Lab
ย 
Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Puppet
ย 

Similar to Service intergration (20)

PHP SA 2014 - Releasing Your Open Source Project
PHP SA 2014 - Releasing Your Open Source ProjectPHP SA 2014 - Releasing Your Open Source Project
PHP SA 2014 - Releasing Your Open Source Project
ย 
PHP code examples
PHP code examplesPHP code examples
PHP code examples
ย 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
ย 
Php Security
Php SecurityPhp Security
Php Security
ย 
Introduction to devsecdotio
Introduction to devsecdotioIntroduction to devsecdotio
Introduction to devsecdotio
ย 
Building Modern and Secure PHP Applications โ€“ Codementor Office Hours with Be...
Building Modern and Secure PHP Applications โ€“ Codementor Office Hours with Be...Building Modern and Secure PHP Applications โ€“ Codementor Office Hours with Be...
Building Modern and Secure PHP Applications โ€“ Codementor Office Hours with Be...
ย 
Hacking with hhvm
Hacking with hhvmHacking with hhvm
Hacking with hhvm
ย 
Nko workshop - node js crud & deploy
Nko workshop - node js crud & deployNko workshop - node js crud & deploy
Nko workshop - node js crud & deploy
ย 
How to send files to remote server via ssh in php
How to send files to remote server via ssh in phpHow to send files to remote server via ssh in php
How to send files to remote server via ssh in php
ย 
secure php
secure phpsecure php
secure php
ย 
Legacy applications - 4Developes konferencja, Piotr Pasich
Legacy applications  - 4Developes konferencja, Piotr PasichLegacy applications  - 4Developes konferencja, Piotr Pasich
Legacy applications - 4Developes konferencja, Piotr Pasich
ย 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
ย 
php part 2
php part 2php part 2
php part 2
ย 
PHP Backdoor: The rise of the vuln
PHP Backdoor: The rise of the vulnPHP Backdoor: The rise of the vuln
PHP Backdoor: The rise of the vuln
ย 
Tomรกลก ฤŒorej - OpenSSH
Tomรกลก ฤŒorej - OpenSSHTomรกลก ฤŒorej - OpenSSH
Tomรกลก ฤŒorej - OpenSSH
ย 
PHP and Databases
PHP and DatabasesPHP and Databases
PHP and Databases
ย 
Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014
ย 
Php talk
Php talkPhp talk
Php talk
ย 
Ssh cookbook v2
Ssh cookbook v2Ssh cookbook v2
Ssh cookbook v2
ย 
Ssh cookbook
Ssh cookbookSsh cookbook
Ssh cookbook
ย 

Recently uploaded

๐Ÿ’š๐Ÿ˜‹ Bilaspur Escort Service Call Girls, 9352852248 โ‚น5000 To 25K With AC๐Ÿ’š๐Ÿ˜‹
๐Ÿ’š๐Ÿ˜‹ Bilaspur Escort Service Call Girls, 9352852248 โ‚น5000 To 25K With AC๐Ÿ’š๐Ÿ˜‹๐Ÿ’š๐Ÿ˜‹ Bilaspur Escort Service Call Girls, 9352852248 โ‚น5000 To 25K With AC๐Ÿ’š๐Ÿ˜‹
๐Ÿ’š๐Ÿ˜‹ Bilaspur Escort Service Call Girls, 9352852248 โ‚น5000 To 25K With AC๐Ÿ’š๐Ÿ˜‹nirzagarg
ย 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrHenryBriggs2
ย 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...roncy bisnoi
ย 
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
ย 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...SUHANI PANDEY
ย 
Lucknow โคCALL GIRL 88759*99948 โคCALL GIRLS IN Lucknow ESCORT SERVICEโคCALL GIRL
Lucknow โคCALL GIRL 88759*99948 โคCALL GIRLS IN Lucknow ESCORT SERVICEโคCALL GIRLLucknow โคCALL GIRL 88759*99948 โคCALL GIRLS IN Lucknow ESCORT SERVICEโคCALL GIRL
Lucknow โคCALL GIRL 88759*99948 โคCALL GIRLS IN Lucknow ESCORT SERVICEโคCALL GIRLimonikaupta
ย 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...singhpriety023
ย 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirtrahman018755
ย 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubaikojalkojal131
ย 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdfMatthew Sinclair
ย 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...SUHANI PANDEY
ย 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC
ย 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...SUHANI PANDEY
ย 
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...SUHANI PANDEY
ย 
Busty DesiโšกCall Girls in Vasundhara Ghaziabad >เผ’8448380779 Escort Service
Busty DesiโšกCall Girls in Vasundhara Ghaziabad >เผ’8448380779 Escort ServiceBusty DesiโšกCall Girls in Vasundhara Ghaziabad >เผ’8448380779 Escort Service
Busty DesiโšกCall Girls in Vasundhara Ghaziabad >เผ’8448380779 Escort ServiceDelhi Call girls
ย 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableSeo
ย 
best call girls in Hyderabad Finest Escorts Service ๐Ÿ“ž 9352988975 ๐Ÿ“ž Available ...
best call girls in Hyderabad Finest Escorts Service ๐Ÿ“ž 9352988975 ๐Ÿ“ž Available ...best call girls in Hyderabad Finest Escorts Service ๐Ÿ“ž 9352988975 ๐Ÿ“ž Available ...
best call girls in Hyderabad Finest Escorts Service ๐Ÿ“ž 9352988975 ๐Ÿ“ž Available ...kajalverma014
ย 

Recently uploaded (20)

๐Ÿ’š๐Ÿ˜‹ Bilaspur Escort Service Call Girls, 9352852248 โ‚น5000 To 25K With AC๐Ÿ’š๐Ÿ˜‹
๐Ÿ’š๐Ÿ˜‹ Bilaspur Escort Service Call Girls, 9352852248 โ‚น5000 To 25K With AC๐Ÿ’š๐Ÿ˜‹๐Ÿ’š๐Ÿ˜‹ Bilaspur Escort Service Call Girls, 9352852248 โ‚น5000 To 25K With AC๐Ÿ’š๐Ÿ˜‹
๐Ÿ’š๐Ÿ˜‹ Bilaspur Escort Service Call Girls, 9352852248 โ‚น5000 To 25K With AC๐Ÿ’š๐Ÿ˜‹
ย 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
ย 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
ย 
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
ย 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
ย 
valsad Escorts Service โ˜Ž๏ธ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service โ˜Ž๏ธ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...valsad Escorts Service โ˜Ž๏ธ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service โ˜Ž๏ธ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
ย 
Thalassery Escorts Service โ˜Ž๏ธ 6378878445 ( Sakshi Sinha ) High Profile Call G...
Thalassery Escorts Service โ˜Ž๏ธ 6378878445 ( Sakshi Sinha ) High Profile Call G...Thalassery Escorts Service โ˜Ž๏ธ 6378878445 ( Sakshi Sinha ) High Profile Call G...
Thalassery Escorts Service โ˜Ž๏ธ 6378878445 ( Sakshi Sinha ) High Profile Call G...
ย 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
ย 
Lucknow โคCALL GIRL 88759*99948 โคCALL GIRLS IN Lucknow ESCORT SERVICEโคCALL GIRL
Lucknow โคCALL GIRL 88759*99948 โคCALL GIRLS IN Lucknow ESCORT SERVICEโคCALL GIRLLucknow โคCALL GIRL 88759*99948 โคCALL GIRLS IN Lucknow ESCORT SERVICEโคCALL GIRL
Lucknow โคCALL GIRL 88759*99948 โคCALL GIRLS IN Lucknow ESCORT SERVICEโคCALL GIRL
ย 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
ย 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
ย 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
ย 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
ย 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
ย 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
ย 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
ย 
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
ย 
Busty DesiโšกCall Girls in Vasundhara Ghaziabad >เผ’8448380779 Escort Service
Busty DesiโšกCall Girls in Vasundhara Ghaziabad >เผ’8448380779 Escort ServiceBusty DesiโšกCall Girls in Vasundhara Ghaziabad >เผ’8448380779 Escort Service
Busty DesiโšกCall Girls in Vasundhara Ghaziabad >เผ’8448380779 Escort Service
ย 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
ย 
best call girls in Hyderabad Finest Escorts Service ๐Ÿ“ž 9352988975 ๐Ÿ“ž Available ...
best call girls in Hyderabad Finest Escorts Service ๐Ÿ“ž 9352988975 ๐Ÿ“ž Available ...best call girls in Hyderabad Finest Escorts Service ๐Ÿ“ž 9352988975 ๐Ÿ“ž Available ...
best call girls in Hyderabad Finest Escorts Service ๐Ÿ“ž 9352988975 ๐Ÿ“ž Available ...
ย 

Service intergration

  • 1. Service Intergration Jang Jaemin jaeminj@gmail.com
  • 2. Openssh + authentication key(1) fabio@morpheus:~$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/fabio/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/fabio/.ssh/id_rsa. Your public key has been saved in /home/fabio/.ssh/id_rsa.pub. The key fingerprint is: 44:3e:ef:58:94:15:52:c2:88:ca:ab:21:43:53:3d:42 fabio@morpheus fabio@morpheus:~$ fabio@morpheus:~$ ssh-keygen -p Enter file in which the key is (/home/fabio/.ssh/id_rsa): Key has comment '/home/fabio/.ssh/id_rsa' Enter new passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved with the new passphrase. fabio@morpheus:~$
  • 3. Openssh + authentication key(2) Install the public key on the servers fabio@morpheus:~$ ssh-copy-id -i .ssh/id_rsa.pub ornellas@apanela.com 15 ornellas@apanela.com's password: Now try logging into the machine, with "ssh 'ornellas@apanela.com'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting. fabio@morpheus:~$
  • 4. freesshd(1) Overview Install and configure FreeSSHd on the server Create keys configure Putty to connect to the server Install FreeSSHd Download FreeSSHd from http://www.freesshd.com/?ctt=download Double click to start installer on the server As a service Accept all other defaults
  • 5. freesshd(2) Configure FreeSSHd Open FreeSSHd settings (may have to kill the service and start manually to get the GUI) SSH tab: Max number = 2 idle = 600 Authentication tab Pub key folder = C:Program Files (x86)freeSSHdkeys Password auth = disabled Pub key auth = required Users tab add login=chef auth = 'Pub key (ssh only)' user can use = shell click OK
  • 6. freesshd(3) Generate Public and Private keys Open PuttyGen Click โ€˜Generateโ€™ move the mouse pointer around as instructed to generate the key Save a Putty compatible private key Click โ€˜Save private keyโ€™ Save this to the client PC, Putty will need this You should really save with a passphrase for extra security Save OpenSSL compatible private key for Chef knife โ€˜Conversionsโ€™ menu > โ€˜Export OpenSSH Keyโ€™ > save as a *.pem Save the public key Copy the contents of โ€˜Public key for pasting into OpenSSH authorized file:โ€™ and paste into a textfile. rename this file โ€˜chefโ€™ (no file extension, the filename must match the user login name created drop this file into the public key folder C:Program Files (x86)freeSSHdkeys on the server.
  • 7. freesshd(4) Connecting with Putty Open Putty (or Putty portable) Enter the IP address of the server Connection type = SSH (obviously!) In the left menu tree Connection > SSH > Auth > โ€˜Private key file for authentication:โ€™ > click browse Select the private key that was generated above Click โ€˜Openโ€™ when prompted โ€˜login:โ€™ > enter โ€˜chefโ€™ > hit enter If the private key was saved with a passphrase then enter this when prompted You should now be connected to the server. ssh -o ConnectTimeOut=10 -o Port='22' -o IdentityFile=key/'id_rsa' -o GSSAPIAuthentication=no -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR 'XXX'@'192.168.XXX.XXX'
  • 8. Sshclient.php <? $this->cli= parent::newClass("sshclient", $ssh_conf); $this->cli->exec( $cmd); $data['stdout'] = $this->stdout ; $data['stderr'] = $this->stderr; ?>
  • 9. JSON, Rest Api , bash, PHP, Powershell
  • 10. Json (Javascript Object Notation) { "glossary": { "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": { "GlossEntry": { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": { "para": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": ["GML", "XML"] }, "GlossSee": "markup" } } } } }
  • 11. Restful api HTTP Method URI Action GET http://[hostname]/todo/api/v1.0/tasks Retrieve list of tasks GET http://[hostname]/todo/api/v1.0/tasks/ [task_id] Retrieve a task POST http://[hostname]/todo/api/v1.0/tasks Create a new task PUT http://[hostname]/todo/api/v1.0/tasks/ [task_id] Update an existing task DELETE http://[hostname]/todo/api/v1.0/tasks/ [task_id] Delete a task
  • 12. PHP Server Side (1) <?php switch ($_SERVER['REQUEST_METHOD'] ) { case 'PUT': case 'POST': case 'GET': case 'HEAD': case 'DELETE': case 'OPTIONS': break; default: break; } ?> .htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-s RewriteRule ^(.*)$ api.php?rquest=$1 [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^(.*)$ api.php [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} -s RewriteRule ^(.*)$ api.php [QSA,NC,L] </IfModule>
  • 13. PHP Server Side (2) <?php $request = file_get_contents('php://input'); // return associative array of JSON $input = json_decode($request, true); $input['request'] = $request; $input['rx_datetime'] = date('Y-m-d H:i:s') ; header("Content-type: application/json"); echo json_encode($input); ?>
  • 14. Bash curl -i -X POST -H "Content-Type: application/json ; charset=UTF-8" -d '{"username":"xyz","password":"xyz"}' http://localhost:3000/api/login curl -i -d @credentials.json -H "Content-Type: application/json" http://localhost:3000/api/login -X [PUT | POST | GET | DELETE] http://blogs.plexibus.com/2010/04/12/rest-esting-with-curl-file-handling/
  • 15. PHP <? $data = array("name" => "Hagrid", "age" => "36"); $data_string = json_encode($data); $ch = curl_init('http://api.local/rest/users'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string)) ); $result = curl_exec($ch, true); curl_Close($ch) $data = json_decode($result, true) ; print_r($data) ?>
  • 16. Powershell Client(1) http://www.powershellcookbook.com/recipe/Vlhv/interact-with-rest-based-web-apis Invoke-RestMethod cmdlet PS > $url = "https://api.stackexchange.com/2.0/questions/unanswered" + "?order=desc&sort=activity&tagged=powershell&pagesize=10&site=stackoverflow" PS > $result = Invoke-RestMethod $url PS > $result.Items | Foreach-Object { $_.Title; $_.Link; "" } PS> $contact = @{ first_name="Jack"; last_name="Smith"; emails=@{preferred="jsmith@contoso.com";business="Jack.Smith@contoso.com"} } | ConvertTo-Json PS> Invoke-RestMethod -Uri "$ApiUri/me/contacts?access_token=$AccessToken" -Method Post -ContentType "application/json" -Body $contact
  • 17. Powershell Client(2) $url = "http://www.seismi.org/api/eqs" $request = [System.Net.WebRequest]::Create($url) $request.Method="Get" $response = $request.GetResponse() $requestStream = $response.GetResponseStream() $readStream = New-Object System.IO.StreamReader $requestStream $data=$readStream.ReadToEnd() if($response.ContentType -match "application/xml") { $results = [xml]$data } elseif($response.ContentType -match "application/json") { $results = $data | ConvertFrom-Json } else { try { $results = [xml]$data } catch { $results = $data | ConvertFrom-Json } } $results