I have a RHEL6 box with no subscription to Red Hat Network. I want to install gcc using yum to resolve all the complex dependencies. Can I connect to Fedora or Centos repositories to install software? If so, how?

the way i'd do it is with yum-plugin-downloadonly on the subscription machine, and keepcache turned on. then move the rpms over.
–
SirexJan 30 '12 at 15:36

Be aware of two things. Firstly, it is a breach of the Red Hat license to have a RHEL system installed without a RHEL entitlement. Secondly, if you have CentOS packages installed, your system will likely not be supported by Red Hat, you may need to reinstall the OS to get tech support from them.
–
jamiebJul 12 '13 at 12:22

So you can download the "centos-release" package from a CentOs mirror for the release of RHEL you have chosen; CentOS Mirrors List, and that will install the CentOS-Base repo files to enable the CentOs repositories to work in RHEL.

A fresh installation of CentOS is always recommended. There will be some problems, and some package cleaning up required if you mix repositories. This is mainly because its a hack to do this, and its not widely tested.

HOWEVER NUMBER 2

CentOS patch levels do not follow the same naming convention as RHEL patches, due to Redhat restrictions and other naming issues.