Ale*_*lex 6 linux ssh unix remote
当我ssh进入mycomputerfrom 时logincomputer,我想自动cd进入 . 上的当前目录(ssh执行命令的目录)mycomputer。特别是:
> cd /tmp/
Run Code Online (Sandbox Code Playgroud)
现在/tmp/是当前工作目录。
> ssh mycomputer
> cd /tmp
Run Code Online (Sandbox Code Playgroud)
我希望这可以通过 1 个命令自动发生。这可能吗?假设两台计算机上的目录结构完全相同。
在 Stack Overflow 上回答。
ssh -t xxx.xxx.xxx.xxx "cd /directory_wanted"
您可以将其添加到 shell 脚本中:
ssh -t xxx.xxx.xxx.xxx "cd \$PWD; bash"