Pages

Monday, April 16, 2012

Setup SSH without password, follow the steps below:-


To setup SSH without password, follow the steps below:-

  • First check if you have generated any DSA key in your client side .ssh folder
  • $ cd ~/.ssh
    $ ls -l
  • If you see any of the file name shown below, then you already have the key, you can skip the next steps (DSA key generation).
  • id_dsa
    id_dsa.pub
  • Enter the command below to generate the DSA key at the client side
  • $ ssh-keygen -t dsa
  • and you will see sth like below. just leave everything blank and press Enter all the way till it end.
  • Generating public/private dsa key pair.
    Enter file in which to save the key (/home/urname/.ssh/id_dsa):
    Created directory '/home/a/.ssh'.
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /home/urname/.ssh/id_dsa.
    Your public key has been saved in /home/urname/.ssh/id_dsa.pub.
    The key fingerprint is:
    4e:3f:05:78:3f:9e:97:6c:3b:ad:e8:58:37:bd:35:d4 urname@yourmachine
  • Now transfer your DSA public key from client to the server using the command below:-
  • $ scp ~/.ssh/id_dsa.pub remoteuser@remotemachine:.ssh/myid_dsa.pub
  • Now, login to the remote machine and make sure the .ssh folder is at right permission
  • $ chmod 700 ~/.ssh
  • At the remote machine, append the myid_dsa.pub to authorized_keys and remove the original key.
  • $ cat myid_dsa.pub >> ~/.ssh/authorized_keys
    $ rm myid_dsa.pub
  • Now change the permission of authorized_key file at the remote server
  • $ chmod 600 ~/.ssh/authorized_keys
  • Configuration done. you may now try to ssh to the remote server. It should not prompt you for any password from now on.

Notes to check if you still not able to ssh without password.

  • check if your remote .ssh folder has 700 permission.
  • If not use the command below:-
  • $ chmod 700 ~/.ssh
  • check if your remote .ssh/authorized_keys has 600 permission. If not then use the command below to change:-
  • $ chmod 600 ~/.ssh/authorized_keys

Copy OS file using plsql

create source directory object

SQL> create directory soruce_dir as '/u01/app/oracle/source';

Directory created.

create target directory object


SQL> create directory target_dir as  '/u01/app/oracle/target';

Directory created.

Now use the copy_file procedure of dbms_file_transfer package as below

Begin
 dbms_file_transfer.copy_file (
 source_directory_object => 'source_dir',
 destination_directory_object => 'dest_dir',
 source_file_name => 'my_file_to_copied',
 destination_file_name => 'my_file_to_copied');
end;

Note that the file that needs to be copied over can’t be larger than 2 terabytes and each file’s size has to be a multiple of 512 bytes.

Query to check datafile / controlfile / spfile backup status


use following query to check db backup status.


SELECT dbfiles||' out of '||numfiles||' datafiles backed up' "Datafiles backed up",
                          cfiles "Control Files backed up", spfiles "SPFiles backed up"
          FROM    (select count(*) numfiles from v$datafile),
                         (select count(*) dbfiles  from v$backup_datafile a, v$datafile b
                          where a.file# = b.file#   and a.completion_time > sysdate - 1),
                         (select count(*) cfiles from v$backup_datafile
                          where file# = 0 and completion_time > sysdate - 1),
                         (select count(*) spfiles from v$backup_spfile
                         where completion_time > sysdate - 1);