写了个 Mac 上简单的 SSH 连接工具,分享一下

2018-01-06 17:06:07 +08:00
 agnewee

因为总是用 ssh 连接需要不断的输密码,找过工具,可能是自己姿势不对,觉得不太好使。

SecureCRT 不知道是我装的不对还是别的什么原因,总是会过一会儿就连接中断。

所以用 Python 基于 expect 写了个简单的工具。

atssh

# 安装
bash build.sh ~/.zshrc

# 使用
atssh IP USERNAME PASSWORD PORT

# 首次连接
atssh 192.168.1.99 root root 22

# 再次连接
atssh 192.168.1.99

atssh

6862 次点击
所在节点    Python
47 条回复
HuHui
2018-01-06 19:11:30 +08:00
iterm2+sshpass
zeyexe
2018-01-06 19:11:43 +08:00
SecureCRT 有个 Anti-idle 的配置,勾选 Send NO-OP 就可以保持连接了。
sunwei0325
2018-01-06 19:50:01 +08:00
试一下 mosh 吧, 你会爱上它的
HandSonic
2018-01-06 20:00:46 +08:00
推荐 Termius
jorneyr
2018-01-06 20:18:24 +08:00
iTerm + expect 脚本,不让贴连接
shino996
2018-01-06 21:21:30 +08:00
@likuku 学到了, 我一直都是直接改 config 的路径…
SeonMe
2018-01-06 21:32:26 +08:00
key 搞定,在 user 目录建一个 .ssh 文件夹(应该都有),再建一个 config 文件 ,里边儿写上 name,host,post 就可以了
SimbaPeng
2018-01-06 23:01:51 +08:00
@tulongtou iTerm2 只是个终端阿,又不是 ssh 管理连接工具
tracyone
2018-01-06 23:26:03 +08:00
连 key 都不知道,写出了 ssh 连接工具,只能 hehe 了。
q397064399
2018-01-07 09:22:36 +08:00
@tracyone #29 谁不是小白过来的。
joysir
2018-01-07 10:23:57 +08:00
用 key,配置 config,直接用别名登录,都不需要记这些。
redapple0204
2018-01-07 12:15:31 +08:00
貌似深度终端有这个工具来着。。
ranye
2018-01-07 13:44:37 +08:00
用 key 登入,然后如下设置下 .ssh/config 就行了

Host *
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/.ssh/id_rsa

Host [whatever]
HostName [IP address]
Port 12345
User root
ServerAliveInterval 10
Kokororin
2018-01-07 15:05:59 +08:00
sshpass
2owe
2018-01-07 17:00:49 +08:00
ssh 可以加一个选项 -o,表示配置自动活跃,令 SSH 连接不会因为长时间无输入自动断掉。
比如:

```
ssh user@host -o ServerAliveInterval=60
```

鉴于折腾可能是无止境的,老夫这里有一份折腾小册子,少侠可以拿去作为参考:

『分享』打通终端到服务器,我推荐它们 https://hit1024.com/post/2016-10-30

内容是关于这些工具的使用和简单配置:iTerm,Zsh,mosh,SSH public-key authentication,Tmux。
labulaka
2018-01-07 22:24:43 +08:00
SecureCRT 里面有一项设置 隔多少秒发数据包给服务器 这样就不会断开了
wizardoz
2018-01-08 09:58:01 +08:00
ssh-copy-id 正解,然后配合上.ssh/config 配置。
详情:man ssh_config
agnewee
2018-01-08 10:40:43 +08:00
@zeyexe @labulaka 感谢,SecureCRT 找到这个设置了。
agnewee
2018-01-08 10:42:15 +08:00
感谢各位大佬,通过 key 确实是一种比较方便的方式。
pangliang
2018-01-08 11:37:49 +08:00
ssh_config + ControlPath 也可以的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/420624

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX