Advertise with Googlier.com Blog do LuisComS http://blog.luiscoms.com.br Tips for developers about validation, versioning, PHP, MySql and others. Wed, 12 Nov 2014 00:06:55 +0000 en-US hourly 1 https://wordpress.org/?v=5.1.19 Convert python dictionary to xml http://blog.luiscoms.com.br/python-en/convert-dictionary-to-xml.lcs http://blog.luiscoms.com.br/python-en/convert-dictionary-to-xml.lcs#respond Mon, 22 Sep 2014 17:52:44 +0000 http://blog.luiscoms.com.br/?p=258 Recently, I needed to create a Python service that returns JSON and XML. There is a struct in Python called dictionary (dict) that is next to JSON and already have a specific class to convert it. So, I created a dictionary structure and was already halfway there. For XML there are another classes, but I […]

The post Convert python dictionary to xml first appeared on Blog do LuisComS.

]]>
Recently, I needed to create a Python service that returns JSON and XML.

There is a struct in Python called dictionary (dict) that is next to JSON and already have a specific class to convert it. So, I created a dictionary structure and was already halfway there.

For XML there are another classes, but I would needed to implement the same logic again and it is a bad smell.

Searching, I found some gists of functions that convert dict to XML but they were not what I needed.

So follow the complete code that I used to create based on another gists.

References:

And you, already had similar situation? Comment it!

The post Convert python dictionary to xml first appeared on Blog do LuisComS.

]]>
http://blog.luiscoms.com.br/python-en/convert-dictionary-to-xml.lcs/feed 0
SSH Public Key Auth http://blog.luiscoms.com.br/quick-posts/ssh-public-key-auth.lcs http://blog.luiscoms.com.br/quick-posts/ssh-public-key-auth.lcs#respond Mon, 23 Jun 2014 16:29:05 +0000 http://blog.luiscoms.com.br/?p=195 If you frequently access hosts using ssh with user and password and do not know public key authentication, this post is for you. I will not explain about advantages and disadvantages, clearly and practically I want to show you how create and use the private key to authenticate on ssh. To create a public key and […]

The post SSH Public Key Auth first appeared on Blog do LuisComS.

]]>
PublicKey Authentication SSH

PublicKey Authentication SSH

If you frequently access hosts using ssh with user and password and do not know public key authentication, this post is for you.

I will not explain about advantages and disadvantages, clearly and practically I want to show you how create and use the private key to authenticate on ssh.

To create a public key and a private key we use the command ssh-keygen

$ ssh-keygen -t dsa

Type enter until create the keys, that will stay at .ssh in your home

$ ls -l ~/.ssh
/home/your_username/.ssh/id_dsa
/home/your_username/.ssh/id_dsa.pub

Now you need copy the content of public key to autorized_key file at the .ssh directory of your remote server.
There are many ways to do it, the simplest may be the following.

$ ssh remote_user@remote_host "echo `cat ~/.ssh/id_dsa.pub` >> ~/.ssh/authorized_keys"

In one line, this command connect to remote host and copy the public key to correct file. Probably you need to type the remote user’s password to login.

Replace remote_user to user that should login in remote host and, logically replace remote_host to server that you want to login.

May occur that the .ssh does not exists in the remote server at the home user directory, to solve it I run the command to create directory if do not exists.

$ ssh remote_user@remote_host mkdir -p .ssh

It is important to stress that the server should be configured to accept public key authentication, where is configured in the file /etc/ssh/sshd_config

# allow public key authentication
PubkeyAuthentication yes

If necessary to reconfigure the server, you need restart the service:
For CentOS

$ svc -du /var/service/sshd/

Plus!

I created a script that does everything at once. You only need to replace the variables that I mentioned above (user and host) and then the script is ready:

I hope this helps.

The post SSH Public Key Auth first appeared on Blog do LuisComS.

]]>
http://blog.luiscoms.com.br/quick-posts/ssh-public-key-auth.lcs/feed 0