venerdì 22 aprile 2011

Linux how to generate a ssh key and copy it to a server

This morning I had to generate a key for a ssh connection to a remote machine where we have our remote internal git repository.

The first step is to generate the key using the command ssh-keygen -t rsa which prompt to enter the key file name, I typed  ~/.ssh/id_rsa and to enter a passphrase (remember if you enter it you will be asked for it every time you want connect to the remote machine)

now in the folder ~/.ssh there are 2 files:

  • id_rsa, the private key
  • id_rsa.pub, the public key
The second step is to copy the public key to the remote machine, to do that use the command ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote_machine 

This is all.

In my case I had an old previous key with a differente name, I deleted it and so the ssh wasn't able to find my key. I discovered becouse every time I tryed to connect to the remote machine with ssh user@remote_machine my password (not my passphrase) was required. So I modified the /etc/ssh/ssh-config file 


Host *
IdentityFile ~/.ssh/id_rsa #the private key location
to use multiple private keys to connect to different servers check http://stackoverflow.com/questions/2419566/best-way-to-use-multiple-ssh-private-keys-on-one-client

giovedì 21 aprile 2011

Delete all svn directory quickly in linux

Sometimes I had the need to remove all .svn folders from a project, a friend of mine told me a quick and easy way (if you are so lucky to work on linux).
From mc (Midnight commander)

  • navigate to the root folder of the project 
  • press F9 and choose from the menu bar Command --> Find File 
  • in the File name field enter .svn
  • delete all from the Content field (leave it empty)
  • press ok
  • when the search end select the option Panelize ... all the finded folder will be shown in the classic mc directory panel
  • select all with the insert keyboard button
  • press F8
All the .svn folders will be removed.

I hope this will be useful for some novice linux user like me :-)