Unable to connect oracle 12 database remotely while local connection works I have two oracle test nodes. On node 2 as root I am able to connect without credential with the command,

su - oraabc -c "/oracle/ABC/12102/bin/sqlplus / as sysdba"


Output:

SQL*Plus: Release 12.1.0.2.0 Production on Tue Jan 15 12:18:20 2019

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL&gt;


I'm trying to connect from node 1. Passwordless login is already established using keys between node 1 and 2.

Command:

ssh root@node2 su - oraabc -c "/oracle/ABC/12102/bin/sqlplus / as sysdba"


But it prompts for credentials,

Output:

SQL*Plus: Release 12.1.0.2.0 Production on Tue Jan 15 12:23:07 2019

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Enter user-name:


Why does it prompt for credentials if oraabc is already a part of the dba group? Is there a configuration missing in order enable remote connection as oracle user without credentials?
Env:

[root@o71 ~]# tail -5 /home/oracle/.bash_profile

export ORACLE_SID=MIN18
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/18.0.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH


Local:

[root@o71 ~]# su - oracle -c "sqlplus / as sysdba"

SQL*Plus: Release 18.0.0.0.0 - Production on Tue Jan 15 15:54:16 2019
Version 18.4.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.


Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL&gt;


Remote:

[root@o72 ~]# ssh root@o71 su - oracle -c "sqlplus / as sysdba "

SQL*Plus: Release 18.0.0.0.0 - Production on Tue Jan 15 15:55:15 2019
Version 18.4.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.

Enter user-name:


Remote with better syntax:

[root@o72 ~]# ssh root@o71 'su - oracle -c "sqlplus / as sysdba "'

SQL*Plus: Release 18.0.0.0.0 - Production on Tue Jan 15 15:55:39 2019
Version 18.4.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.


Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL&gt;


Instead of:

ssh root@node2 su - oraabc -c "/oracle/ABC/12102/bin/sqlplus / as sysdba"


Use this:

ssh root@node2 'su - oraabc -c "/oracle/ABC/12102/bin/sqlplus / as sysdba"'


Also I find it really bad practice to set these variables in profile by default. Just use oraenv.

Example:

[root@o72 ~]# ssh root@o71 'su - oracle -c "export ORAENV_ASK=NO; export ORACLE_SID=MIN18; . oraenv; sqlplus / as sysdba "'
The Oracle base remains unchanged with value /u01/app/oracle

SQL*Plus: Release 18.0.0.0.0 - Production on Tue Jan 15 15:56:51 2019
Version 18.4.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.


Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL&gt;