First of all check which sudo is executed in your eshell session.
It can be your system’s sudo:
$ which sudo
/path/to/system/wide/sudo
$ which *sudo
/path/to/system/wide/sudo
or eshell’s sudo:
$ which sudo
sudo is a compiled Lisp function in `em-tramp.el'
$ which eshell/sudo
eshell/sudo is a compiled Lisp function in `em-tramp.el'
Eshell’s sudo uses TRAMP's su or sudo method. These commands are in the eshell-tramp module, which is disabled by default.
I will cover eshell’s sudo case, because it is internal to Emacs and it does not depend on your OS distro:
Load eshell-tramp module:
(require 'em-tramp) ; to load eshell’s sudo
Switch to eshell’s sudo
by prefering built-in commands
(setq eshell-prefer-lisp-functions t)
It seems that in Emacs 24.4 we need to set
(setq eshell-prefer-lisp-variables t)
by creating an alias (execute snippet in eshell)
alias sudo 'eshell/sudo $*'
Aliases defined (or deleted) by the alias command are automatically written to the file named by eshell-aliases-file, which you can also edit directly (although you will have to manually reload it).
Finally enable password caching for eshell’s sudo (and TRAMP):
(setq password-cache t) ; enable password caching
(setq password-cache-expiry 3600) ; for one hour (time in secs)
PS If you have changed your prompt with eshell-prompt-function, then remember to adjust prompt regex eshell-prompt-regexp accordingly. Wrong prompt regex can break some eshell functionality — including password detection.