[英]How to use sshpass when loging in to remote server with Emacs / Tramp
I found a related thread that describes how to login to a remote server using sshpass
: 我找到了一个相关的线程,描述了如何使用
sshpass
登录远程服务器:
sshpass -p '<password>' <ssh/scp command>
How can logging in with password be accomplished in Emacs / Tramp? 如何在Emacs / Tramp中完成使用密码登录 ?
I presently use the following and then enter the password manually: 我目前使用以下内容,然后手动输入密码:
C-x C-f /ssh:user@server:/home/user/public_html/
I have the following function, that I access from my right-click context pop-up menu: 我有以下功能,我从右键单击上下文弹出菜单访问:
(defun lawlist-remote-server-login ()
(interactive)
(find-file "/ssh:user@server:/home/user/public_html/"))
If you're simply trying to avoid typing your password, but you don't want to use SSH keys, you can use an authentication file. 如果您只是想避免输入密码,但又不想使用SSH密钥,则可以使用身份验证文件。
From the TRAMP user manual : 从TRAMP用户手册 :
4.12.1 Using an authentication file
4.12.1使用身份验证文件
The package
auth-source.el
, originally developed in No Gnus, offers the possibility to read passwords from a file, like FTP does it from~/.netrc
.最初在No Gnus中开发的包
auth-source.el
source.el提供了从文件中读取密码的可能性,就像FTP从~/.netrc
读取密码一样。 The default authentication file is~/.authinfo.gpg
, this can be changed via the variableauth-sources
.默认的身份验证文件是
~/.authinfo.gpg
,可以通过变量auth-sources
来更改。A typical entry in the authentication file would be
验证文件中的典型条目是
machine melancholia port scp login daniel password geheim
The port can be any tramp method (see Inline methods , see External methods ), to match only this method.
端口可以是任何tramp方法(请参阅内联方法 ,请参阅外部方法 ),以仅匹配此方法。 When you omit the port, you match all tramp methods.
省略端口时,将匹配所有tramp方法。
In case of problems, setting
auth-source-debug
tot
gives useful debug messages.如果出现问题,将
auth-source-debug
设置为t
提供有用的调试消息。
Edit: 编辑:
The specific code that worked for the OP without requiring GnuPG is reproduced below. 在不需要GnuPG的情况下为OP工作的特定代码再现如下。
Emacs configuration: Emacs配置:
(setq auth-sources '("/Users/HOME/.0.data/.0.emacs/.authinfo"))
And in the .authinfo
file identified above: 在上面标识的
.authinfo
文件中:
machine 12.34.56.789 login lawlist password 12345678 port ssh
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.