我怎么能直接ssh到一个特定的目录? [英] How can I ssh directly to a particular directory?
本文介绍了我怎么能直接ssh到一个特定的目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我经常登录到几台服务器之一,去在这些机器的几个目录之一。目前我做这种东西:
I often have to login to one of several servers and go to one of several directories on those machines. Currently I do something of this sort:
localhost ~]$ ssh somehost
Welcome to somehost!
somehost ~]$ cd /some/directory/somewhere/named/Foo
somehost Foo]$
我可以确定我需要进入哪个主机和目录的脚本,但我不能想出一个办法做到这一点:
I have scripts that can determine which host and which directory I need to get into but I cannot figure out a way to do this:
localhost ~]$ go_to_dir Foo
Welcome to somehost!
somehost Foo]$
有一个简单,聪明的或任何方式做到这一点?
Is there an easy, clever or any way to do this?
推荐答案
您可以执行以下操作:
ssh -t xxx.xxx.xxx.xxx "cd /directory_wanted ; bash"
这样,你会得到一个shell权利directory_wanted。
This way, you will get a shell right on the directory_wanted.
这篇关于我怎么能直接ssh到一个特定的目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文