[英]Using Emacs TRAMP with an ssh server that doesn't provide /bin/sh?
I am trying to use Emacs TRAMP to access files over ssh on a server that does not provide /bin/sh
, and so I get the following error when I try to connect: 我试图使用Emacs TRAMP在不提供/bin/sh
的服务器上通过ssh访问文件,因此当我尝试连接时出现以下错误:
env: can't execute '/bin/sh': No such file or directory
Is there any way to tell TRAMP where the remote shell is for that server? 有没有办法告诉TRAMP远程shell用于该服务器的位置? (The "server" is a tethered Android phone, so sh in at /system/bin/sh
.) (“服务器”是一个系留Android手机,所以在/system/bin/sh
。)
See also the docstring for the tramp-methods
variable. 另请参见tramp-methods
变量的docstring。 This part would appear noteworthy: 这部分看起来值得注意:
tramp-remote-shell
This specifies the shell to use on the remote host. 这指定了要在远程主机上使用的shell。 This MUST be a Bourne-like shell. 这必须是一个类似Bourne的shell。 It is normally not necessary to set this to any value other than "/bin/sh": Tramp wants to use a shell which groks tilde expansion, but it can search for it. 通常没有必要将其设置为“/ bin / sh”以外的任何值:Tramp想要使用一个可以进行波形扩展的shell,但它可以搜索它。 Also note that "/bin/sh" exists on all Unixen, this might not be true for the value that you decide to use. 另请注意,所有Unixen上都存在“/ bin / sh”,对于您决定使用的值,这可能不正确。 You Have Been Warned. 你被警告了。
Edit: 编辑:
So here's a way you could create a new method based on an existing one ("scpc" in this example), and then give the custom method a different remote shell: 所以这里有一种方法可以创建一个基于现有方法的新方法(在本例中为“scpc”),然后为自定义方法提供一个不同的远程shell:
(require 'tramp)
(let* ((base-method (cdr (assoc "scpc" tramp-methods)))
(new-method (copy-tree base-method))
(rshell (assq 'tramp-remote-shell new-method)))
(setcdr rshell "/system/bin/sh")
(add-to-list 'tramp-methods (cons "android" new-method)))
Note that in Emacs 23 (Tramp 2.1.20), this property was named tramp-remote-sh
. 请注意,在Emacs 23(Tramp 2.1.20)中,此属性名为tramp-remote-sh
。 In Emacs 24 (Tramp 2.2.3-24.1) it has been changed to tramp-remote-shell
. 在Emacs 24(Tramp 2.2.3-24.1)中,它已被更改为tramp-remote-shell
。
And I'm guessing that you can use this method by default for your specified host with this: 我猜你可以默认使用这个方法为你指定的主机:
(add-to-list
'tramp-default-method-alist
(list "\\`myhost\\'" nil "android"))
ssh expects to use the remote user's login shell. ssh希望使用远程用户的登录shell。 If you have root access to the server, you can change the entry in the passwd file: 如果您具有服务器的root访问权限,则可以更改passwd文件中的条目:
:blah:blah:user_name:blah:/path/to/shell :嗒嗒:嗒嗒:USER_NAME:嗒嗒:/路径/到/壳
Or just symlink /bin/sh to it. 或者只是symlink / bin / sh。
I don't believe there is any way to change this from the client's side, but if there is, you would need to tell ssh
, not TRAMP. 我不相信有任何方法可以从客户端改变这一点,但如果有,你需要告诉ssh
,而不是TRAMP。 (You could do this via an ssh_config file.) (您可以通过ssh_config文件执行此操作。)
Edit: I stand corrected. 编辑:我纠正了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.