<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog do Finger</title>
	<atom:link href="http://leandrofinger.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://leandrofinger.com</link>
	<description>Conhecimento nunca é demais!</description>
	<lastBuildDate>Fri, 26 Jun 2009 19:12:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Psql sem senha somente para root</title>
		<link>http://leandrofinger.com/2009/06/26/psql-sem-senha-somente-para-root/</link>
		<comments>http://leandrofinger.com/2009/06/26/psql-sem-senha-somente-para-root/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 18:17:22 +0000</pubDate>
		<dc:creator>Finger</dc:creator>
				<category><![CDATA[Banco de Dados]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[segurança]]></category>

		<guid isPermaLink="false">http://leandrofinger.com/?p=77</guid>
		<description><![CDATA[Me surgiu uma necessidade de um script que rode através do Crontab e faça inserções no banco de dados usando o comando COPY (grande volume de dados), isso só pode ser feito através do Psql. Mas como fazer para não pedir senha e manter o sistema seguro? Então eu, junto com o Everton, meu colega [...]]]></description>
			<content:encoded><![CDATA[<p>Me surgiu uma necessidade de um script que rode através do Crontab e faça inserções no banco de dados usando o comando COPY (grande volume de dados), isso só pode ser feito através do Psql. Mas como fazer para não pedir senha e manter o sistema seguro? Então eu, junto com o Everton, meu colega de Celepar, pesquisamos e encontramos à seguinte solução.</p>
<p>Softwares utilizados:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">Sistema Operacional: Ubuntu 9.04
Versão do PostgreSQL: 8.3</pre></div></div>

<p>Primeiramente, abra um terminal como root. Depois entre no diretório onde se encontram os arquivos de configuração do Postgres:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postgresql<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8.3</span><span style="color: #000000; font-weight: bold;">/</span>main<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Agora vamos editar o arquivo pg_ident.conf, para criarmos um mapeamento entre o usuário da máquina (root) e o usuário do BD (Ex: coletor):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> pg_ident.conf</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;"># No map names are defined in the default configuration.  If all ident
# user names and PostgreSQL user names are the same, you don't need
# this file.  Instead, use the special map name &quot;sameuser&quot; in
# pg_hba.conf.
&nbsp;
# MAPNAME     IDENT-USERNAME    PG-USERNAME
nopasswd	root		 coletor</pre></div></div>

<p>Salve e feche o arquivo, agora vamos adicionar a regra para que o <em>psql</em> não solicite senha para o usuário <em>coletor</em>, quando estivermos logados como <em>root</em>. Abra e edite o arquivo pg_hba.conf, como abaixo.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> pg_hba.conf</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;"># TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
&nbsp;
local	all		postgres		ident sameuser
local	all		coletor			ident nopasswd
# &quot;local&quot; is for Unix domain socket connections only
#local   all         all                               ident sameuser
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
#host    all         all         ::1/128               md5</pre></div></div>

<p>A primeira linha deste arquivo significa que se você fizer um psql para o usuário <em>postgres</em>,  será feita uma verificação da identidade da requisição, através do mapeamento padrão <em>sameuser</em>. Na segunda linha, inserimos a nossa regra, ou seja, requisições para o usuário <em>coletor</em>, serão verificadas com o mapeamento <em>nopasswd</em>, que é o nosso mapeamento. As demais linhas não nos interessam no momento. Salve e feche o arquivo.</p>
<p>Agora para funcionar, devemos reiniciar o serviço do Postgres.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>postgresql-<span style="color: #000000;">8.3</span> restart</pre></div></div>

<p>Pronto, agora é só testar. <strong>Mas atenção!!!!</strong> No comando <em>psql</em> não se esqueça de indicar o nome do usuário e o banco de dados.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">psql <span style="color: #660033;">-U</span> coletor meu_bd</pre></div></div>

<p>Um abraço.</p>
]]></content:encoded>
			<wfw:commentRss>http://leandrofinger.com/2009/06/26/psql-sem-senha-somente-para-root/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Boot PXE via USB com gPXE</title>
		<link>http://leandrofinger.com/2009/06/25/boot-pxe-via-usb-com-gpxe/</link>
		<comments>http://leandrofinger.com/2009/06/25/boot-pxe-via-usb-com-gpxe/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 02:05:15 +0000</pubDate>
		<dc:creator>Finger</dc:creator>
				<category><![CDATA[Rede]]></category>
		<category><![CDATA[boot]]></category>
		<category><![CDATA[gPXE]]></category>
		<category><![CDATA[PXE]]></category>
		<category><![CDATA[usb]]></category>

		<guid isPermaLink="false">http://leandrofinger.com/?p=70</guid>
		<description><![CDATA[Esta foi uma necessidade minha e estou compartilhando a solução com vocês.
Instalando o gPXE
Utilizando uma máquina Linux, baixe o arquivo tar.gz da versão mais atual do gPXE em http://kernel.org/pub/software/utils/boot/gpxe/
Abra um Terminal como root e entre no diretório onde o arquivo foi salvo.
Descompacte o arquivo:

tar xzvf gpxe-X.X.X.tar.gz

Entre no diretório gpxe-X.X.X/src:

cd gpxe-X.X.X/src

Instale os pacotes necessários:

apt-get install syslinux [...]]]></description>
			<content:encoded><![CDATA[<p>Esta foi uma necessidade minha e estou compartilhando a solução com vocês.</p>
<p><strong>Instalando o gPXE</strong></p>
<p>Utilizando uma máquina Linux, baixe o arquivo tar.gz da versão mais atual do gPXE em <a href="http://kernel.org/pub/software/utils/boot/gpxe/">http://kernel.org/pub/software/utils/boot/gpxe/</a><br />
Abra um Terminal como root e entre no diretório onde o arquivo foi salvo.</p>
<p>Descompacte o arquivo:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">tar xzvf gpxe-X.X.X.tar.gz</pre></div></div>

<p>Entre no diretório gpxe-X.X.X/src:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">cd gpxe-X.X.X/src</pre></div></div>

<p>Instale os pacotes necessários:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">apt-get install syslinux mtools gcc</pre></div></div>

<p>Compile os módulos:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">make</pre></div></div>

<p><strong>Gravando no Pendrive</strong></p>
<p>Insira o pendrive e verifique nas informações mostradas no Terminal, qual é o dispositivo referente ao pendrive. Ex: [sda], [sdb], etc.</p>
<p>Agora compile a imagem para USB:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">make bin/gpxe.usb</pre></div></div>

<p>Grave a imagem no pendrive, onde X é a letra referente ao dispositivo:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">dd if=bin/gpxe.usb of=/dev/sdX</pre></div></div>

<p>Depois disso é só sacar o pendrive e usar.</p>
]]></content:encoded>
			<wfw:commentRss>http://leandrofinger.com/2009/06/25/boot-pxe-via-usb-com-gpxe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache com SSL (Https)</title>
		<link>http://leandrofinger.com/2009/04/25/apache-com-ssl-https/</link>
		<comments>http://leandrofinger.com/2009/04/25/apache-com-ssl-https/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 01:06:36 +0000</pubDate>
		<dc:creator>Finger</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[certificado digital]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[segurança]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://leandrofinger.com/?p=27</guid>
		<description><![CDATA[Olá pessoal,
Neste vou descrever os passos para criar um certificado digital e configurar o Apache para trabalhar com SSL. Semana passada executei este procedimento em um Linux Debian Lenny e hoje vou mostrar com base no Ubuntu Hardy.
Supondo que você já está com o Apache2 instalado, vamos instalar o pacote openssl. Abra um terminal e [...]]]></description>
			<content:encoded><![CDATA[<p>Olá pessoal,<br />
Neste vou descrever os passos para criar um certificado digital e configurar o Apache para trabalhar com SSL. Semana passada executei este procedimento em um Linux Debian Lenny e hoje vou mostrar com base no Ubuntu Hardy.</p>
<p>Supondo que você já está com o Apache2 instalado, vamos instalar o pacote openssl. Abra um terminal e digite o seguinte comando:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> openssl</pre></div></div>

<p>Depois vamos criar um diretório para salvar nosso certificado.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>certs
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>certs</pre></div></div>

<p>Agora chegamos ao certificado. Nós só precisaremos de um dos dois comandos abaixo, o primeiro deles gera um certificado protegido por uma frase secreta e o segundo não, a diferença está no parâmetro <em>-des3</em>. No meu caso eu utilizei o segundo deles, pois caso você precise reiniciar o apache ou a máquina, esta a frase secreta lhe será solicitada e no caso de um restart acidental do servidor, o apache não iniciará o serviço enquanto este frase não for digitada.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> openssl genrsa <span style="color: #660033;">-des3</span> <span style="color: #660033;">-out</span> server.key <span style="color: #000000;">1024</span></pre></div></div>

<p>ou</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> openssl genrsa  <span style="color: #660033;">-out</span> server.key <span style="color: #000000;">1024</span></pre></div></div>

<p>Digite o comando <em>ls</em> e verifique se o arquivo server.key foi criado. Se não, execute novamente o passo anterior, caso contrário, continuamos. Este próximo comando irá gerar o certificado com base na chave gerada pelo comando anterior.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-x509</span> <span style="color: #660033;">-days</span> <span style="color: #000000;">1825</span> <span style="color: #660033;">-key</span> server.key <span style="color: #660033;">-out</span> server.crt</pre></div></div>

<p>Nesse comando você deve ter notado o parâmetro <em>-days 1825</em>, isso significa que a validade do seu certificado é de 1825 dias ou 5 anos, você pode alterar esse valor mas não é recomendável aumentar mais que isso. Continuando&#8230;&#8230;. Responda o questionário com as informações do certificado.</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:BR
State or Province Name (full name) [Some-State]:Paraná
Locality Name (eg, city) []:Curitiba
Organization Name (eg, company) [Internet Widgits Pty Ltd]:FingerHome
Organizational Unit Name (eg, section) []:Bedroom
Common Name (eg, YOUR name) []:Leandro Finger Romanovski
Email Address []:eu@leandrofinger.com</pre></div></div>

<p>Digite novamente o comando <em>ls</em> e verifique agora se o arquivo server.crt foi criado. Pronto, esse é o nosso certificado. Agora vamos configurar o Apache para utilizá-lo. Vá até o diretório sites-available e edite um arquivo novo com o nome do seu site.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>sites-available<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> gedit meusite-ssl</pre></div></div>

<p>Esse arquivo deve conter as informações do nosso site.</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">443</span>&gt;
	<span style="color: #00007f;">Servername</span> www.meudominio.com.br
	<span style="color: #00007f;">ServerAdmin</span> admin@meudominio.com.br
	<span style="color: #00007f;">DocumentRoot</span> /var/www/
	<span style="color: #00007f;">CustomLog</span> /var/log/apache2/access_ssl.log combined
	<span style="color: #00007f;">ErrorLog</span> /var/log/apache2/error_ssl.log
	<span style="color: #00007f;">LogLevel</span> notice
        SSLEngine <span style="color: #0000ff;">on</span>
        SSLCertificateFile /etc/apache2/certs/server.crt
        SSLCertificateKeyFile /etc/apache2/certs/server.key
        <span style="color: #00007f;">ServerSignature</span> <span style="color: #0000ff;">On</span>
	&lt;<span style="color: #000000; font-weight:bold;">Directory</span> /var/www/&gt;
		<span style="color: #00007f;">Options</span> <span style="color: #0000ff;">Indexes</span> <span style="color: #0000ff;">FollowSymLinks</span> MultiViews
		<span style="color: #00007f;">AllowOverride</span> <span style="color: #0000ff;">None</span>
		<span style="color: #00007f;">Order</span> <span style="color: #00007f;">allow</span>,<span style="color: #00007f;">deny</span>
		<span style="color: #00007f;">allow</span> <span style="color: #00007f;">from</span> <span style="color: #00007f;">all</span>
	&lt;/<span style="color: #000000; font-weight:bold;">Directory</span>&gt;
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;
&nbsp;
<span style="color: #00007f;">Alias</span> / /var/www/blog/
&lt;<span style="color: #000000; font-weight:bold;">Location</span> /&gt;
	SSLRequireSSL
	<span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">403</span> https://www.meudominio.com.br/
&lt;/<span style="color: #000000; font-weight:bold;">Location</span>&gt;</pre></div></div>

<p>Salve e feche o arquivo. Agora vamos habilitar o módulo de SSL no Apache. No terminal digite o comando abaixo.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> a2enmod ssl</pre></div></div>

<p>Verifique no arquivo ports.conf se o apache está habilitado para escutar na porta 443, a porta padrão para Https.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gedit <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>ports.conf</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">Listen</span> <span style="color: #ff0000;">80</span>
&nbsp;
<span style="color: #00007f;">Listen</span> <span style="color: #ff0000;">443</span></pre></div></div>

<p>Agora é só reiniciar o Apache e tudo certo.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> apache2ctl restart</pre></div></div>

<p>Grande abraço.</p>
]]></content:encoded>
			<wfw:commentRss>http://leandrofinger.com/2009/04/25/apache-com-ssl-https/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>O Recomeço</title>
		<link>http://leandrofinger.com/2009/04/21/o-recomeco/</link>
		<comments>http://leandrofinger.com/2009/04/21/o-recomeco/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 21:48:39 +0000</pubDate>
		<dc:creator>Finger</dc:creator>
				<category><![CDATA[Geral]]></category>
		<category><![CDATA[conhecimento]]></category>
		<category><![CDATA[recomeço]]></category>

		<guid isPermaLink="false">http://leandrofinger.com/?p=6</guid>
		<description><![CDATA[Olá pessoal,
Depois de alguns meses com o blog fora do ar, por alguns motivos técnicos e pessoais, estou de volta. Com o mesmo objetivo de trazer informação útil e de forma fácil de ser compreendida para os profissionais de TI em geral. Tentarei trazer várias dicas relacionadas ao meu dia-a-dia, bem como desafios superados, para [...]]]></description>
			<content:encoded><![CDATA[<p>Olá pessoal,</p>
<p>Depois de alguns meses com o blog fora do ar, por alguns motivos técnicos e pessoais, estou de volta. Com o mesmo objetivo de trazer informação útil e de forma fácil de ser compreendida para os profissionais de TI em geral. Tentarei trazer várias dicas relacionadas ao meu dia-a-dia, bem como desafios superados, para que outras pessoas não se desgastem para alcançar o mesmo objetivo.</p>
<p>Quero novamente pedir aos meus amigos e visitantes deste blog que fiquem à vontade em comentar os posts, solicitar alguns assuntos e até mesmo enviar posts para serem colocados aqui. Desta forma desejo manter este blog como uma fonte rica de conhecimento para os profissionais de TI.</p>
<p>Por enquanto é isto, vou ficando por aqui. Para entrar em contato comigo, envie um e-mail para finger.le at gmail dot com.</p>
]]></content:encoded>
			<wfw:commentRss>http://leandrofinger.com/2009/04/21/o-recomeco/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
