如何使SSH直接进入特定目录? [英] How to make SSH go directly to specific directory?
问题描述
当你做一个ssh second_machine你可以连接到主目录下的second_machine
when you do an "ssh second_machine" you are able to connect to second_machine on your home directory
但通常我正在my_machine在目录中工作很长的路径,我想连接到second_machine并立即移动到我的工作目录。所以每次我必须:
But usually i am working in my_machine in directory with very long path, and i want to connect to second_machine and move to my working directory right away. So everytime i have to:
ssh second_machine
cd / very / long / path / to / directory / / p>
ssh second_machine
cd /very/long/path/to/directory/
有没有办法让它自动? (ssh自动转到所需的目录)
Is there a way to make it automatic ?? ( ssh automatically go to the desired directory )
推荐答案
这应该适合你
ssh -t second_machine "cd /very/long/path/to/directory/; bash"
假设你想要运行bash,如果需要,替换不同的shell。
Assumes you're wanting to run bash, substitute for a different shell if required.
这篇关于如何使SSH直接进入特定目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!