金仓数据库KingbaseES V8R6 root用户securecmd连接_Permission denied_错误

案例分析:
在KingbaseES V8R6数据库在不支持ssh连接的系统环境,可以通过securecmdd服务建立主机之间的通讯,默认securecmdd服务建立用户之间的互信,通过publickey认证建立访问连接。在配置securecmdd服务后,默认kingbase和root用户都可以通过publickey建立连接。 本案例描述了在建立root用户的连接时,出现‘permission denied’错误的解决方法。

适用版本:

KingbaseES V8R6

一、问题现象

用户在执行sys_backup.sh init时,出现以下故障:
file

执行建立主机连接的securecmd的执行语句,出现‘permission denied’错误。

file

二、问题分析

1、查看securecmdd服务目录和文件

securecmdd服务在部署和配置后,将建立以下的目录和文件:

# 目录属主和权限
[root@node102 ~]# ls -lhd /etc/.kes
drwxr-xr-x. 3 root root 65 Aug 10  2022 /etc/.kes
[root@node102 ~]# ls -lhd /root/.es
drwx------. 2 root root 40 Sep 28  2022 /root/.es
[root@node102 ~]# ls -lhd /home/kingbase/.es
drwx------. 2 kingbase kingbase 40 Sep 28  2022 /home/kingbase/.es
[root@node102 ~]# ls -lhd /root
dr-xr-x---. 10 root root 4.0K Apr  3 10:15 /root
[root@node102 ~]# ls -lhd /home/kingbase
drwx------. 31 kingbase kingbase 4.0K Apr  3 10:15 /home/kingbase

# 文件属主和权限
[root@node102 ~]# ls -lh /etc/.kes
total 8.0K
drwxr-xr-x. 2 root root   6 Mar 29  2022 empty
-rwxr-xr-x  1 root root 315 Aug 10  2022 securecmd_config
-rwxr-xr-x  1 root root 603 Aug 10  2022 securecmdd_config
[root@node102 ~]# ls -lh /root/.es
total 8.0K
-rw------- 1 root root  381 Sep 28  2022 accept_hosts
-rw------- 1 root root 1.7K Sep 28  2022 key_file
[root@node102 ~]# ls -lh /home/kingbase/.es
total 8.0K
-rw------- 1 kingbase kingbase  381 Sep 28  2022 accept_hosts
-rw------- 1 kingbase kingbase 1.7K Sep 28  2022 key_file

---如果以上目录和文件的权限出现问题,将在建立securecmd连接时会出现此类故障。

2、分析securecmd连接

如下图所示,分析securecmd连接过程,在建立publickey认证后,读取key_file私钥文件无响应,转为password认证,但输入root用户密码后,报’permission denied‘错误。
file

3、建立securecmdd服务debug分析

1)以debug方式启动securecmdd服务

[root@node101 ~]# /home/kingbase/cluster/R6HA/kha/kingbase/bin/sys_securecmdd -D -ddd
debug2: load_server_config: filename /etc/.kes/securecmdd_config
debug2: load_server_config: done config len = 560
debug2: parse_server_config_depth: config /etc/.kes/securecmdd_config len 560
debug3: /etc/.kes/securecmdd_config:1 setting Port 8899
debug3: /etc/.kes/securecmdd_config:3 setting HostKey ~/.es/key_file
debug3: /etc/.kes/securecmdd_config:4 setting AuthorizedKeysFile .es/accept_hosts
debug3: /etc/.kes/securecmdd_config:5 setting PidFile /var/run/sys_securecmdd.pid
......
debug2: fd 3 setting O_NONBLOCK
debug1: Bind to port 8899 on 0.0.0.0.
Server listening on 0.0.0.0 port 8899.

2)客户端建立连接

[root@node101 ~]#  /home/kingbase/cluster/R6HA/kha/kingbase/bin/sys_securecmd root@127.0.0.1 'date'
root@127.0.0.1's password:

3)查看连接debug信息
如下图所示,出现/root的属主或权限错误:
file

4)检查/root的属主
如下图所示,/root的属主竟然是kingbase !!!
file

三、问题解决

将/root的属主改为root.root后,问题解决。

四、权限错误案例

1、修改/root目录为777(默认550)

[root@node101 bin]# ls -lhd /root
drwxrwxrwx. 26 root root 4.0K Apr  3 11:51 /root

2、故障现象

[kingbase@node101 bin]$ ./sys_securecmd -vv root@127.0.0.1  'date'
OpenSSH_8.6p1, OpenSSL 1.0.2k  26 Jan 2017
debug2: resolve_canonicalize: hostname 127.0.0.1 is address
......
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /home/kingbase/.ssh/id_rsa RSA SHA256:bDj4e2SR8hakpiI5ADaqqiYuh7KzknAD2hWbPGBRtUg
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
......
debug2: we did not send a packet, disable method
debug1: Next authentication method: password
root@127.0.0.1's password:
debug2: we sent a password packet, wait for reply
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
root@127.0.0.1's password:

---如上所示,出现publickey连接的认证错误。   

3、查看securecmd连接debug信息

如下图所示,debug信息出现/root属主或权限错误。
file

五、总结

对于securecmdd服务,在建立用户的publickey的认证访问后,经常会出现用户访问需要password认证或‘ permission denied’等故障问题。当出现类似问题,重点查看securecmdd相关目录和文件的权限及属主,以及kingbase和root用户宿主目录的权限和属主。 更多信息,参见https://help.kingbase.com.cn/v8/index.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值