这是一个使用未加密的小型自定义文件的示例。在这个例子中,文件名是.authinfo_iphone
,它只包含一行——我用它通过 ssh 连接到我越狱的 iphone:
machine localhost login root password alpine port ssh
然后,我使用一个小函数进行连接:
(defun lawlist-remote-iphone-data ()
(interactive)
(let ((auth-sources '("/Users/HOME/.0.data/.0.emacs/.authinfo_iphone")))
(find-file "/ssh:root@localhost#2222:/private/var/mobile/.0.data/")))
您还可以使用外部实用程序,例如sshpass
然后编写一个函数——命令行如下所示:
/usr/bin/sshpass -p 'my-password' ssh my-username@12.34.56.789
这是一个示例函数,它结合了该命令行以通过 ssh 登录 iPhone。它认为已经有一个打开的 shell 模式缓冲区,其中进程名为*shell*
.
(defun shell-iphone ()
"From an existing shell buffer with a process named `*shell*`,
log-in to the iPhone using sshpass."
(interactive)
(let* (
(password "alpine")
(port "2222")
(username "root")
(host "localhost")
(sshpass "/Users/HOME/.0.data/.0.emacs/bin/sshpass")
(ssh "/usr/bin/ssh")
(dir "/private/var/mobile/.0.data"))
(comint-send-string "*shell*"
(mapconcat 'identity `(
,sshpass
"-p"
,password
,ssh
"-p"
,port
"-l"
,username
,host
"-t"
"\"cd " ,dir " && bash --login\"") " "))
(comint-send-input)))