1

Tramp with dired-mode can use the authinfo file to automatically login. This avoids setting up keys in the .ssh directory and also on the remote server.

Q:  How can I modify the behavior of eshell to access the authinfo file to automatically login to a remote server.

[CAVEAT: I do not want to piggy-back by opening a Tramp dired-mode buffer and then launching eshell -- i.e., I want eshell to access the authinfo file without the help of dired-mode.]

[I am aware of the option to use a utility called sshpass, but I'd like to use the authinfo file.]

1

All operations in eshell dedicated for a remote server are mapped to Tramp. If you are in a local directory, you could switch to a remote directory like this:

Welcome to the Emacs shell

~ $ cd /sudo::
/sudo:root@detlef:/root $ 

This will ask you for the password via Tramp, meaning authinfo. What exactly does not work for you?

  • I would like to type at a command prompt in a local directory (e.g., on my home computer): ssh username@ip-address -p 2222 and login to the remote server (e.g., in cyberspace) without being prompted for a password, such that eshell accesses the authinfo file for the password if it can find one -- if no password is found, then prompt me. – lawlist Feb 25 '17 at 19:25
  • That's not supported, AFAIK. But why do you need this? Tramp functionality is available in eshell. Try the following commands in your eshell prompt: cd /ssh:username@ip-address#2222: and then hostname. You will see, that the hostname command has been executed on the remote host. – Michael Albinus Feb 26 '17 at 17:52
  • Thank you -- I'll give this a try in a day or so and I'll look at eshell/cd to see what makes it tick in terms of activating the functions that use the authinfo file (e.g., tramp-read-password). I previously created a custom eshell-send-input function that can accept a fourth argument in the form of a string such as "ls -la /". My ultimate goal will be to create a function that will launch eshell (or find it if it's already open) and login to the remote server (under the hood of eshell) and then update the buffer with a new prompt for the remote once logged in using authinfo. – lawlist Feb 26 '17 at 18:39
  • If you want to make it programmatically, it is sufficient to bind default-directory to the remote server. Something like (let ((default-directory "/ssh:username@ip-address#2222")) <call your eshell functions>) . Tramp comes in, and does the password ping-pong with you. – Michael Albinus Feb 27 '17 at 8:13
  • Wow! That little tip is an Emacs life-changing event for me. To avoid Host name must not match method "ssh", I added the path on the remote server (shared account): (let ((default-directory "/ssh:username@ip-address#2222:/home/username")) (eshell)) Thank you. :) – lawlist Feb 27 '17 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.