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.68k stars 100 forks source link

支持记住密码登录 #7

Closed smallevilbeast closed 1 year ago

smallevilbeast commented 1 year ago

支持配置密码登录 并记住 ?

lonnywong commented 1 year ago

要支持其实是可以的。但是,感觉不是很安全?别人可以从配置文件中看到密码是什么。

不过,现在用的私钥好像也是能直接看到,和密码的安全性感觉差不多。

如果想要这个功能的人多,感觉可以在 ~/.ssh/config 中加一个密码配置项,然后直接用配置的密码登录。

smallevilbeast commented 1 year ago

是啊 能用密码的 都是本地测试机为主 方便

lonnywong commented 1 year ago

我周末实现一下吧,想用的可以用,不想用的也不影响。

~/.ssh/config 中配置,支持通配的,如:

Host alias1
    HostName 192.168.0.1
    Port 22
    User your_name
    Password 123456

Host alias*
    Password 111111
mapleafgo commented 1 year ago

觉得在终端第一次输入密码后,可以确认下是否保存,保存的话加密存储在配置文件中。

这样实现会不会更安全?

lonnywong commented 1 year ago

觉得在终端第一次输入密码后,可以确认下是否保存,保存的话加密存储在配置文件中。

tssh 不写 ~/.ssh/config 文件的,要搞的话会比较复杂。

加密的话,就一定会有一个密钥,这个密钥只能内置在 tssh 中,会看代码的人是很容易解密出明文密码的。

这个周末我会先实现一个明文密码的。其实私钥也是“明文”,有权限读取 ~/.ssh/id_* 内容的用户,都能拿到。

更安全一点的,是不让别人能解锁自己的电脑,设置好 ~/.ssh 的权限,私钥再加一个 passphrase 。

这个私钥 passphrase 我还在想怎么实现会比较好,提前要用户输入 passphrase 好像不太好,因为可能最终用不上这个私钥。

smallevilbeast commented 1 year ago

太赞了 我现在完全用tssh 替代 其他ssh管理工具了 , alias t="tssh" 超方便

lonnywong commented 1 year ago

@smallevilbeast 已支持“记住密码”,用法详见 README.md

安装办法:

go install github.com/trzsz/trzsz-ssh/cmd/tssh@main
smallevilbeast commented 1 year ago

测试了通过 :+1:

一个小问题

🧨 microbee_datacenter (192.168.0.88) microbee* ()

microbee* 这个只有密码的配置项,是不是可以隐藏掉

lonnywong commented 1 year ago

microbee* 这个只有密码的配置项,是不是可以隐藏掉

@smallevilbeast 过滤掉了这些了

smallevilbeast commented 1 year ago

谢谢 十分OK

smallevilbeast commented 1 year ago

@lonnywong 在.ssh/config中 设置Password 使用git 会保错

➜  myblog git:(master) git push origin master
/home/evilbeast/.ssh/config: line 51: Bad configuration option: password
/home/evilbeast/.ssh/config: terminating, 1 bad configuration options
fatal: 无法读取远程仓库。

自定义字段 我们是不是用自己的配置文件路径

lonnywong commented 1 year ago

@smallevilbeast 这个是 git 使用了 openssh ,然后 openssh 报错了。 可以让 git 使用 tssh 的,现在 main 分支的 tssh 已经支持 git 了,例如可以这样配置:

git config --global core.sshCommand "/usr/local/bin/tssh"
lonnywong commented 1 year ago

@smallevilbeast 我将密码配置项改到了 ~/.ssh/password 中。

smallevilbeast commented 1 year ago

可以了