Host key verification failed.

在客户现场配置ssh的时候,在root用户下可以正常使用ssh,但是切换到普通用户下就报错了:
[root@pg dev]# ssh pg
The authenticity of host 'pg (186.168.100.14)' can't be established.
RSA key fingerprint is 6f:90:3e:ed:eb:3e:c8:b1:bb:e4:c9:1c:f3:8e:0e:88.
Are you sure you want to continue connecting (yes/no)? no
Host key verification failed.

[postgres@pg ~]$ ssh pg
Host key verification failed.

经检查,是/dev/tty权限不足:
[root@pg dev]# ll tty
crw-------. 1 root tty 5, 0 Feb 11 20:06 tty

[root@pg dev]# chmod 666 tty
[root@pg dev]# ll tty
crw-rw-rw-. 1 root tty 5, 0 Feb 11 20:06 tty


root@pg dev]# su - postgres
[postgres@pg ~]$ ssh pg
The authenticity of host 'pg (186.168.100.14)' can't be established.
RSA key fingerprint is 6f:90:3e:ed:eb:3e:c8:b1:bb:e4:c9:1c:f3:8e:0e:88.
Are you sure you want to continue connecting (yes/no)? no
Host key verification failed.
[postgres@pg ~]$

这样就可以使用了。

附:
 
Host key verification failed.一般解决办法:
.1 .ssh/known_hosts 裡面记录的目标主机 key 值不正确。这是最普遍的情况,只要删除对应的主机记录就能恢复正常。
2. .ssh 目录或者 .ssh/known_hosts 对当前用户的权限设置不正确。
3. /dev/tty 对 other 用户没有放开读写权限。

你可能感兴趣的:(Linux)