How to Fix ORA-01031 insufficient privileges - sqlplus / as sysdba

Ok ,ok... here is what took me about 2 hours on my time today. One colleague of mine cloned an Oracle Home to a new server and passed it to me to create a duplicate oracle database a production database into the new Oracle installed home. So i am trying to login the empty instance using the sqlplus utility and i get the error:

ORA-01031: insufficient privileges
What the hell .... !!! All the parameters are set ORACLE_SID, ORACLE_HOME, TNS_ADMIN, etc.. What now ? First thing i did i have commented the SQLNET.AUTHENTICATION_SERVICES parameter from the sqlnet.ora file but with no success. Finally after many failed tests and try's i have reached the solution thanks to post on stack page. So here is the solution:  There is a file in your $ORACLE_HOME/rdbms/lib called config.c. This file holds the os groups that the oracle users is included in. This groups in my case the dba group was not declared in the config.c file, during the Oracle_Home cloning the groups were not replicated as on the source host. Here is the content of the file after update:
/*  SS_DBA_GRP defines the UNIX group ID for sqldba adminstrative access.  */
/*  Refer to the Installation and User's Guide for further information.  */

/* IMPORTANT: this file needs to be in sync with
              rdbms/src/server/osds/config.c, specifically regarding the
              number of elements in the ss_dba_grp array.

#define SS_DBA_GRP "dba"
#define SS_OPER_GRP ""
#define SS_ASM_GRP ""

char *ss_dba_grp[] = {SS_DBA_GRP, SS_OPER_GRP, SS_ASM_GRP};
After you update the config.c file you will need to generate a new config.o file. 
  • make copy of the config.o file before.
mv config.o config.bck.001
  Re-link Oracle now
[oracle@node12xv lib]$ make -f ioracle
chmod 755 /u00/app/oracle/product/

 - Linking Oracle
rm -f /u00/app/oracle/product/
gcc  -o /u00/app/oracle/product/ -m64 -L/u00/app/oracle/prod
uct/ -L/u00/app/oracle/product/ -L/u00/app/oracl
e/product/   -Wl,-E /u00/app/oracle/product/
b/opimai.o /u00/app/oracle/product/ /u00/app/oracle/produ
ct/  -Wl,--whole-archive -lperfsrv11 -Wl,--no-whole-archiv

e /u00/app/oracle/product/ /u00/app/oracle/product/
/lib/naeet.o /u00/app/oracle/product/ /u00/app/oracle/product/11.
2.0.2/db_1/lib/naedhs.o /u00/app/oracle/product/  -lserver
11 -lodm11 -lcell11 -lnnet11 -lskgxp11 -lsnls11 -lnls11  -lcore11 -lsnls11 -lnls11 -lcore1
1 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11 -lclient11
 -lvsn11 -lcommon11 -lgeneric11 -lknlopt if /usr/bin/ar tv /u00/app/oracle/product/11.2.0
.2/db_1/rdbms/lib/libknlopt.a | grep xsyeolap.o  /dev/null 2&1 ; then echo "-loraolap11"
 ; fi -lslax11 -lpls11  -lrt -lplp11 -lserver11 -lclient11  -lvsn11 -lcommon11 -lgeneric1
1 if [ -f /u00/app/oracle/product/ ] ; then echo "-lavsr
ver11" ; else echo "-lavstub11"; fi if [ -f /u00/app/oracle/product/
bavclient11.a ] ; then echo "-lavclient11" ; fi -lknlopt -lslax11 -lpls11  -lrt -lplp11 -
ljavavm11 -lserver11  -lwwg  cat /u00/app/oracle/product/

After all this is done try to connect to the instance using the sqlplus 
[[email protected] lib]$ sqlplus / as sysdba

SQL*Plus: Release Production on Mon May 4 18:08:38 2015

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

Conectado a:
Oracle Database 11g Enterprise Edition Release - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
I would recommend you bounce the instance as well.