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'
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>