It took me a while to figure out the correct incantation to log in to another machine and change user account with sudo: `sudo -u someuser -i`. It’s actually very easy once you know how:
.emacs
(set-default 'tramp-default-proxies-alist (quote (("remote.domain" "someuser" "/ssh:%h:"))))
In emacs:
C-x C-f /sudo:someuser@remote.domain:/some/dir
There’s some nice code on http://www.gnu.org/software/tramp/ to display the hostname in the mode-line:
(defconst my-mode-line-buffer-identification (list '(:eval (let ((host-name (or (file-remote-p default-directory 'host) (system-name)))) (if (string-match "^[^0-9][^.]*\\(\\..*\\)" host-name) (substring host-name 0 (match-beginning 1)) host-name))) ": %12b")) (setq-default mode-line-buffer-identification my-mode-line-buffer-identification) (add-hook 'dired-mode-hook '(lambda () (setq mode-line-buffer-identification my-mode-line-buffer-identification)))