trzsz / trzsz-ssh

trzsz-ssh ( tssh ) is an ssh client designed as a drop-in replacement for the openssh client. It aims to provide complete compatibility with openssh, mirroring all its features, while also offering additional useful features. Such as login prompt, batch login, remember password, automated interaction, trzsz, zmodem(rz/sz), udp mode like mosh, etc.
https://trzsz.github.io/ssh
MIT License
1.66k stars 98 forks source link

BUG反馈:new knownhosts failed: open /etc/ssh/ssh_known_hosts: permission denied #77

Closed devome closed 7 months ago

devome commented 8 months ago

在debian 12 中安装了仓库主编译好的deb文件,普通非root用户使用tssh xxx命令(xxx已经配置在~/.ssh/config中了),然后提示以下信息:

new knownhosts failed: open /etc/ssh/ssh_known_hosts: permission denied

很奇怪,普通用户不是应该读取~/.ssh/known_hosts吗?另外,文件/etc/ssh/ssh_known_hosts不存在,以及Debian 12的~/.ssh/known_hosts是加密的,像这样:

|1|135pXXXXXXXXXXXX=|MyRXXXXXXXXXqiQy7cg1UEGI= ssh-ed25519 AAAACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXNFB/VuDWZ1mPUG6ifqbtuYFz

debug日志为:

debug: ~/.tssh.conf does not exist
debug: open config [~/.ssh/config] success
debug: decode config [~/.ssh/config] success
debug: open config [/etc/ssh/ssh_config] success
debug: decode config [/etc/ssh/ssh_config] success
debug: extended config [~/.ssh/password] does not exist
debug: ssh agent address is not set
debug: will attempt key: ~/.ssh/root@xxx ssh-ed25519 SHA256:OomiXXXXXXXXXXXXXXXXXXXXXXXXXXX
debug: add auth method: public key authentication
debug: add auth method: keyboard interactive authentication
debug: add auth method: password authentication
debug: add UserKnownHostsFile: ~/.ssh/known_hosts
debug: UserKnownHostsFile [~/.ssh/known_hosts2] does not exist
debug: add GlobalKnownHostsFile: /etc/ssh/ssh_known_hosts
debug: GlobalKnownHostsFile [/etc/ssh/ssh_known_hosts2] does not exist
new knownhosts failed: open /etc/ssh/ssh_known_hosts: permission denied

自己先创建好~/.ssh/known_hosts2也没有用。

lonnywong commented 8 months ago

这是参考 https://manpages.debian.org/bookworm/openssh-client/ssh_config.5.en.html#GlobalKnownHostsFile 实现的,一般 /etc/ssh/ssh_known_hosts 是有读权限的。

你用 openssh 的 ssh 登录会报错,或者有告警吗?

devome commented 8 months ago

这是参考 https://manpages.debian.org/bookworm/openssh-client/ssh_config.5.en.html#GlobalKnownHostsFile 实现的,一般 /etc/ssh/ssh_known_hosts 是有读权限的。

你用 openssh 的 ssh 登录会报错,或者有告警吗?

原版ssh一切正常。

lonnywong commented 8 months ago

我周末抽空看看怎么兼容。

lonnywong commented 8 months ago

你现在可以在 ~/.ssh/config 中加一个配置项 GlobalKnownHostsFile 来规避。

devome commented 8 months ago

GlobalKnownHostsFile

好的,GlobalKnownHostsFile配置暂时可以解决。

lonnywong commented 8 months ago

我举个倒子:

Host xxx
    GlobalKnownHostsFile /dev/null
lonnywong commented 7 months ago

已修复