Problem
Trying to connect to remote database fails with -956 error
Solution
PROBLEM
When you try to connect to a remote database through dbaccess or an other application you get returned an error -956:
-956
Client client-name is not in /etc/hosts.equiv on the remote host.
This operation cannot be completed because the specified remote computer does not recognize the name of the client computer (the local host, whose name the hostname command returns). Client names are normally recorded in the configuration file /etc/hosts.equiv. The rhosts file on the remote computer might also need modification. For more information on these files and the relation between them, try man rhosts on a UNIX system. See the remote host administrator to ensure that the client host name is specified in /etc/hosts.equiv file for the remote host. This message appears in versions prior to Version 6.0.
-956
Client client-name or user is not trusted by the database server.
The desired database server does not consider the client computer or your user ID trusted. Ask the system administrator to include the client computer as a trusted host and/or your user id as a trusted user in the /etc/hosts.equiv file on the server computer or in the .rhosts file in your home directory on the server computer. See the UNIX manual pages on HOSTS.EQUIV(5) for more information.
Alternatively, you can explicitly specify your user name and password in the USER clause of a CONNECT statement or in the .netrc file in your home directory on the client computer. See the IBM Informix Guide to SQL: Syntax for information on the CONNECT statement, and the UNIX manual pages regarding NETRC(5) for information on the .netrc file. This message appears with Version 6.0 and later.
SCOPE
The following products and operating systems are affected:
Product Name
|
Product Version(s)
|
Hardware Vendor
|
Operating System
|
IBM® Informix® Dynamic Server™
|
|
All
|
All
|
x can be U, H, or F depending on your operating system.
SOLUTION
Check the following files on both local and remote sides, verify if they respect the following entries and try the connection again.
Local side
$INFORMIXDIR/etc/sqlhosts (or $INFORMIXSQLHOSTS file):
DBSERVERALIASES_machine_server onsoctcp machine_server serviceA
/etc/hosts:
IPmachine_server machine_server
IPmachine_client machine_client
/etc/hosts.equiv:
+user (login of the person who is trying to connect)
/etc/services:
serviceA num_serviceA/tcp
serviceB num_serviceB/tcp
$HOME/.rhosts:
IP_machine_cliente machine_cliente
IP_machine_server machine_server
Remote side
$INFORMIXDIR/etc/sqlhosts (or $INFORMIXSQLHOSTS file):
DBSERVERALIASES_machine_cliente onsoctcp machine_cliente serviceB
/etc/hosts:
IPmachine_server machine_server
IPmachine_client machine_client
/etc/hosts.equiv:
+user (login of the person who is trying to connect)
/etc/services:
serviceA num_serviceA/tcp
serviceB num_serviceB/tcp
$HOME/.rhosts:
IP_machine_cliente machine_cliente
IP_machine_server machine_server
从一台服务器连接到另外一台有informix数据库时,出现
Client host or user (informix@datacenter) is not trusted by the server.
解决办法:
在数据库服务器上/ets/hosts.equiv文件(如果没有创建)中添加用户,格式如下:
59.57.251.34 informix
datacenter informix
附:hosts.equiv文件
一、hosts.equiv文件的用途
hosts.equiv文件是为了便于远程主机在本地计算机上执行远程命令而设计的。
/etc/hosts.equiv和$HOME/.rhosts定义了哪些计算机和用户可以不用提供口令就在本地计算机上执行远程命令,如rexec, rcp, rlogin等等。这些不需要提供口令的计算机和用户称为受信任的。
当本地计算机收到执行远程命令的请求时,相应的远程命令服务进程,如rlogind,首先检查/etc/hosts.equiv来确认请求是否来自受信任的计算机和用户。如果这个文件不存在或者虽然存在但不包括相应的计算机和用户,服务进程就会去检查$HOME/.rhosts文件。
/etc/hosts.equiv的权限必须设置为只有root能够写,建议权限为600。如果这个文件被设置为同组或其它用户可写,远程命令服务进程就会忽略它的存在。
如果远程命令是由root用户发起的,远程命令服务进程会忽略/etc/hosts.equiv文件的存在而去直接检查/.rhosts文件。
在指定受信任的计算机和用户时要非常小心,因为这有可能会造成安全漏洞。
二、hosts.equiv文件的格式
添加对计算机/用户的信任:
hostname: 信任计算机hostname上的所有普通用户
hostname username:信任计算机hostname上的用户username
+:信任所有计算机上的所有普通用户
禁止对计算机/用户的信任:
如果计算机名和用户都没有在/etc/hosts.equiv中被定义为受信任的,那么它们就是不受信任的。另外,您还可以用以下方法明确地禁止对计算机/用户的信任。
-hostname:不信任计算机hostname上的所有用户
hostname -username: 不信任计算机hostname上的用户username
hosts.equiv与NIS:
在/etc/hosts.equiv中也可以指定是否信任NIS网络组(NETGROUP)。
+@netgroup: 信任网络组netgroup中的所有计算机
-@netgroup:禁止信任网络组netgroup中的所有计算机
hostname +@netgroup: 信任来自计算机hostname的所有网络组netgroup的成员用户的请求
hostname -@netgroup: 禁止信任来自计算机hostname的所有网络组netgroup的成员用户的请求
/etc/hosts.equiv中记录的顺序:
在/etc/hosts.equiv文件中,记录的顺序十分重要。远程命令服务进程在检查/etc/hosts.equiv文件时会在第一个匹配发现后返回,也就是说,下面这个例子中的禁止信任记录是不起作用的:
hostname
hostname -user1
计算机hostname上的用户user1将能够在不提供口令的情况下在本地计算机上执行远程命令。而下面这个例子能够提供期望中的结果:
hostname -user1
hostname
三、/etc/hosts.equiv示例
1、允许远程计算机emerald 和 amethyst 上的所有用户在本地执行远程命令而无须提供口令:
emerald
amethyst
2、允许远程计算机emerald 上的所有用户和 amethyst 上的用户 greygory 在本地执行远程命令而无须提供口令:
emerald
amethyst gregory
3、允许用户 peter 从任何远程计算机在本地执行远程命令而无须提供口令:
emerald
amethyst gregory
+ peter
4、允许所有是 century 网络组成员的远程计算机上的所有用户在本地执行远程命令而无须提供口令:
emerald
amethyst gregory
+ peter
+@century
5、允许所有在计算机citrine上又是 engineers 网络组成员的用户在本地执行远程命令而无须提供口令:
emerald
amethyst gregory
+ peter
+@century
citrine +@engineers
6、 允许所有是 servers 网络组成员的远程计算机上的所有属于 sysadmins 网络组的用户在本地执行远程命令而无须提供口令:
emerald
amethyst gregory
+ peter
+@century
citrine +@engineers