如何停止“ ssh user@domain.com"一遍又一遍地

发布于 2025-01-19 03:23:11 字数 320 浏览 3 评论 0 原文

我的工作流程始终包括打开一个新的终端窗口,输入 ssh [email protected] (或scp),然后是cd remote/directory/of/project

该域名很长且难以键入,而且它是一个很大的文件路径,因此每次大约需要 20 秒。您会看到高级开发人员采用的规范、有效的方法是什么?

My workflow always consists of opening a new terminal window, typing ssh [email protected] (or scp) followed by cd remote/directory/of/project

The domain is long and hard to type, as well as it being a big file path so this takes me ~20 seconds every time. What's the canonical, efficient way to do this that you would see a senior dev doing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故事未完 2025-01-26 03:23:11

您可以使用要执行的命令创建一个脚本文件,这样您就可以直接执行它,而不必每次都手动键入 ssh/scp/cd 命令。

You can create a script file with the commands you want to execute so you can just execute it instead of manually typing your ssh/scp/cd commands every time you have to do so.

凝望流年 2025-01-26 03:23:11

对于不重新输入 ssh [email protected]通常,您可以将其放入 .ssh/config 中:

Host my_alias
HostName domain.com
User user

之后,您只需输入 ssh my_alias 即可。

为了不重新输入路径,您可以

  • 将路径放在 .bashrc 中的别名中(alias cd_my_proj='cd remote/directory/of/project'
  • 查找它在 bash 历史记录中(通常使用 Ctrl+R)
  • 使用软链接(ln -s remote/directory/of/project ~
  • 在 tmux(或 screen)会话中保持路径打开

您也可以谷歌这些指针以获取更多详细信息(例如如何保存 tmux 会话以及 .ssh/config 中的更多详细信息)

For not retyping ssh [email protected] that often, you can put it in you .ssh/config:

Host my_alias
HostName domain.com
User user

Afterwards, you can just type ssh my_alias.

For not retyping the path, you can

  • put the path in an alias in your .bashrc (alias cd_my_proj='cd remote/directory/of/project')
  • look it up in your bash history (usually with Ctrl+R)
  • use a soft link (ln -s remote/directory/of/project ~)
  • keep the path open in a tmux (or screen) session

You may also google these pointers for more details (like how to save tmux session and further details in your .ssh/config)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文