【发布时间】:2026-02-16 05:25:01
【问题描述】:
我厌倦了这样做。
ssh me@somehost.com
input my password
sudo su - someuser
input my password
cd /some/working/directory
<run some commands>
有没有办法自动化这个?我需要一个特殊的外壳吗?还是shell模拟器?我能否以编程方式将 shell 驱动到某个点然后在其上运行手动命令?
它的奖励积分是用 python 编程的,以获得额外的黑客优势
编辑:下面的所有答案都集中在问题的“完全自动化”部分:困难的部分是我上面强调的部分。这是另一个例子,看看我是否能抓住本质。
ssh me@somehost.com
<get a shell because keys are setup>
sudo su - user_that_deploys_the_app
<input password, because we don't want to give passwordless sudo to developers>
cd env; source bin/activate
cd /path/where/ur/app/is/staging
<edit some files, restart the server, edit some more, check the logs, etc.>
exit the term
【问题讨论】:
-
你能扩展你的问题吗?什么终端命令?适用于哪个操作系统?什么样的自动化?用例?
-
我肯定会尝试一些甜美的日本机器人。
-
离题 - 移至服务器故障
-
@CarlosZ 起始操作系统将是 mac,目标是任何你可以通过 ssh 进入的操作系统。用例是停止重复的事情,自动化的类型将是到这个盒子做这个,然后到另一个盒子做那个。
标签: python linux macos shell ssh