Friday, February 27, 2009

SSH without PassWord

Steps:

  1. On the client run the following commands:

    $ mkdir -p $HOME/.ssh $ chmod 0700 $HOME/.ssh $ ssh-keygen -t dsa -f $HOME/.ssh/id_dsa -P '' 
    This should result in two files, $HOME/.ssh/id_dsa (private key) and $HOME/.ssh/id_dsa.pub (public key).
  2. Copy $HOME/.ssh/id_dsa.pub to the server.

  3. On the server run the following commands:

    $ cat id_dsa.pub >> $HOME/.ssh/authorized_keys2 $ chmod 0600 $HOME/.ssh/authorized_keys2 
    Depending on the version of OpenSSH the following commands may also be required:
    $ cat id_dsa.pub >> $HOME/.ssh/authorized_keys $ chmod 0600 $HOME/.ssh/authorized_keys 
    An alternative is to create a link from authorized_keys2 to authorized_keys:
    $ cd $HOME/.ssh && ln -s authorized_keys2 authorized_keys 
  4. On the client test the results by ssh'ing to the server:

    $ ssh -i $HOME/.ssh/id_dsa server 
  5. (Optional) Add the following $HOME/.ssh/config on the client:

    Host server          IdentityFile ~/.ssh/id_dsa 
    This allows ssh access to the server without having to specify the path to the id_dsa file as an argument to ssh each time.

Wednesday, January 14, 2009

Linux : Delete / Move / Copy remote Files

I am posting this as I had this issue and had a hard time to figure out the solution.

To delete any files from the remote machine we can use the following -:

 ssh -l psadmin -q xx.xx.xxx.xxx rm /xxx/xxxx/saurabh/1/asjdhl.txt

To Move files 
 ssh -l psadmin -q xx.xx.xxx.xxx mv /xxx/xxxx/saurabh/1/asjdhl.txt  /opt/customer/saurabh/2/

You will be prompted for a password though, however you may want to write a simple shell to do the same.


---saurabh

Monday, January 14, 2008

Generate .xls directly from oracle.

Hi Guys,

Please let me know if anybody has any idea about creating .xls from oralce procedure or SQL prompt.

Thanks
Saurabh