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.74k stars 102 forks source link

client to server cipher 能添加加密算法吗 #84

Closed conanlm closed 9 months ago

conanlm commented 9 months ago

failed: ssh: handshake failed: ssh: no common algorithm for client to server cipher; client offered: [aes128-gcm@openssh.com aes256-gcm@openssh.com chacha20-poly1305@openssh.com aes128-ctr aes192-ctr aes256-ctr], server offered: [aes128-cbc 3des-cbc des-cbc]

我登录交换机,报这个错

lonnywong commented 9 months ago

这几个已经不太安全了,不过可以特殊支持一下,参考:https://github.com/golang/go/issues/20201

通过 https://manpages.debian.org/bookworm/openssh-client/ssh_config.5.en.html#Ciphers 来特殊配置某台机:

Host xxx
    Ciphers +aes128-cbc

注意,tssh v0.1.18 未支持这个功能,后面有空再搞,欢迎提个 PR 过来。

conanlm commented 9 months ago

谢谢,是几台老交换机有这问题,新的都没问题

lonnywong commented 9 months ago

还依赖 https://github.com/golang/go/issues/64779 这个 merge 之后,才能支持。

conanlm commented 9 months ago

谢谢,我找到login.go,直接添加了加密算法,倒是可以登录上去了。

Config: ssh.Config{
    Ciphers: []string{"aes128-ctr", "aes192-ctr", "aes256-ctr", "aes128-gcm@openssh.com", "arcfour256", "arcfour128", "aes128-cbc"},
},

我再厚脸皮提个需求,能做个自动交互完后,返回个日志文件的功能吗? 批量运行脚本,最后需要确认一下是否运行成功

lonnywong commented 9 months ago

你可以写个脚本批量调用 tssh 的,如:

tssh xxx "do xxx && echo success" > log.txt
conanlm commented 9 months ago

你可以写个脚本批量调用 tssh 的,如:

tssh xxx "do xxx && echo success" > log.txt

谢谢,我去试试

lonnywong commented 9 months ago

已支持配置 Ciphers

v0.1.19 发布前,可以这样安装 go install github.com/trzsz/trzsz-ssh/cmd/tssh@main,安装的路径在 ~/go/bin/

Host xxx
    Ciphers +aes128-cbc

上面这样配置,或者 tssh -c +aes128-cbc xxx 这样登录。