1833355 Members
3836 Online
110051 Solutions
New Discussion

Remote login

 
System Dude_1
Frequent Advisor

Remote login

Dear user,

I would like to get an opinion from anyone of you to solve my problem. I would like to create a shell script to do remote login using root from server a and to login to server b using oracle. At the same time i would like to encrypt the password for oracle so nobody can read it from my shell script.
Performance Issue on HP-UX 10.20
16 REPLIES 16
Thierry Poels_1
Honored Contributor

Re: Remote login

Hi,
Oracle passwords should NEVER be placed in any script:
1. for obvious security reasons.
2. when you change the Oracle password (as you do regularly ;) your script will fail.

As an alternative create an Oracle user with external authentication (the former ops$users) which will be able to enter Oracle without password (authentication will be done at OS level): "sqlplus /" will be sufficient to enter Oracle.
regards,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
System Dude_1
Frequent Advisor

Re: Remote login

Could elaborate more on how to do that and could root be able run svrmgrl using your recommendation and at the same time would it be access by all or should we specify which user could be place under authentication
Performance Issue on HP-UX 10.20
Thierry Poels_1
Honored Contributor

Re: Remote login

svrmgrl?? do you just want to startup & shutdown your database from a script? Or do you want to querry and/or update your data from a script?
If you are talking about startup/shutdown things are less complex: "su - oracle $ORACLE_HOME/bin/dbstart" and dbshut would probable be all you need.
regards,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
System Dude_1
Frequent Advisor

Re: Remote login

I've tried to use su - oracle but it doesn't wotk as it will just login as root but will not run my script.
Performance Issue on HP-UX 10.20
Magdi KAMAL
Respected Contributor

Re: Remote login

Salam alaikoum Jamaludin,

In order to remote shell a command from serverA ( user root ) to serverB ( user oracle ), do the following :

1. Create a file with name ".rhosts" in the home directory of user Orcale on server b.
The content of this file is only the following line:

serverA +

2. chown oracle:dba .rhosts
( I suppose that the group of user oracle is the standard oracle group : dba ).

3. chmod 400 .rhosts

4. from serverA issue your command like :

remsh serverB -l oracle -n " yourCommand options..."

5. Standard output and error will be directed to serverA.

Notice : I suppose that the name resolution of serverB is solved either by /etc/hosts or DNS.

Magdi
Thierry Poels_1
Honored Contributor

Re: Remote login

Hi,
if you have a standard oracle setup, the following should work from serverA (if .rhosts has been setup):

from serverA:
remsh serverB "/sbin/init.d/oracle stop"
or
remsh serverB "/sbin/init.d/oracle start"

(/sbin/init.d/oracle contains the $ORACLE_HOME/bin/dbstart)
good luck,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Magdi KAMAL
Respected Contributor

Re: Remote login

Again,

As you could see, you don't need to give any oracle password in the command, this validation is done implicitly via .rhosts file.

Magdi
System Dude_1
Frequent Advisor

Re: Remote login

Asslamualaikum Magdi Kamal,

I've tried your solution but it give me the same error on my previous attemp which is Oracle Server Manager Release 2.3.4.0.0 - Production

Copyright (c) Oracle Corporation 1994, 1995. All rights reserved.

Oracle7 Server Release 7.3.4.4.0 - Production
With the distributed, replication and parallel query options
PL/SQL Release 2.3.4.4.0 - Production

SVRMGR> MGR-11401: input error, unable to read input line
MGR-01508: unable to close the current file

Rgrds

Jamal
Performance Issue on HP-UX 10.20
Magdi KAMAL
Respected Contributor

Re: Remote login

Jamal,

You output is :
SVRMGR> MGR-11401: input error, unable to read input line
MGR-01508: unable to close the current file

----

Sounds like you are trying to give an input file to the Oracle Server Manager. ->
This file must be on the remote server and you may refrence it by giving an absolute path.

may you attach what you are doing to easy debug !

Magdi
System Dude_1
Frequent Advisor

Re: Remote login

the content of file I need to execute are as follows :
#!/bin/sh

ORACLE_HOME=/opt/oracle/product/7.3.4 ; export ORACLE_HOME
ORACLE_SID=TEST; export ORACLE_SID

echo $ORACLE_SID
$ORACLE_HOME/bin/svrmgrl <connect internal
select UPPER(TABLESPACE_NAME) from dba_tablespaces order by TABLESPACE_NAME;
quit
echo "\nOnline Backup Completed."
EOF
Performance Issue on HP-UX 10.20
Thierry Poels_1
Honored Contributor

Re: Remote login

hi again,

at first view the 'echo "\nOnline Backup Completed."' should be placed after the 'EOF' because it does not belong to the svrmgrl commands.
good luck,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Magdi KAMAL
Respected Contributor

Re: Remote login

Jamal,

The before EOF statment :
echo "\nOnline Backup Completed."
should be put after the closing EOF.

Because, Oracle Server Manager try to interprete it as part of the set of commands.

Magdi


System Dude_1
Frequent Advisor

Re: Remote login

Still doesn't work
Performance Issue on HP-UX 10.20
Thierry Poels_1
Honored Contributor

Re: Remote login

hey Jamal,

I tried your script and it worked like a charm,
I just replaced 'quit' by 'exit' ;)
You do execute the script as user oracle?
regards,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Magdi KAMAL
Respected Contributor

Re: Remote login

Look Jamal,

I simulate your case:
Your script is running locally without problems, but when you run it remotely you MUST explicitly specify all your environment variables and to refrence all commands with its absolute path.

1. In the begining of your script : set all variables that you need .
2. If you reference any command, reference it with it's absolute path.

Verification :
1. logon to the remote system ( A ).
2. type the env command

3. logon to the local system ( B )
4. remote shell the command env on remote server ( A )

5. Compare the result from 2 and 4 : They are not equal ... and more : point 4 reports only six variables in the environment.

Magdi
Wodisch
Honored Contributor

Re: Remote login

Hello Jamaludin,

do you have an "Oracle password file" set for that
instance? It would be located in "$ORACLE_HOME/dbs/"
and have a name like "ora$ORACLE_SID.pwd" or the
like. Move it aside, then, temporarily (but it is needed,
when you try to start the instance remotely with the
Oracle Enterprise Manager commands).

Anyway, check wether the unix-login you are using
is member of the group "dba" (or whatever group you
have used on installation of Oracle).

HTH,
Wodisch