I have the following code, which works well to a point:

(defun sudo-shell-as-user (host user &optional arg)
  "Use sudo to open a shell on HOST as USER
The password it asks for is the root password on the specified machine."
  (interactive "sMachine? \nsUser? ")
  (let* ((tramp-default-proxies-alist
      `((,(regexp-quote host)
         ,(regexp-quote user)
         "/ssh:root@%h:")))
     (dir "")
     (bname)
     (arg (if arg arg 1))
     (newone (if (not (string-match "/sudo:" default-directory)) t nil))
     (default-directory (if newone (concat "/sudo:" user "@" host ":") 
default-directory)))
    (setq bname (concat "*ssh-sudo:" user "@" host "*<" (number-to-string arg) 
">"))
    (shell bname)
    (if (string-match dir ".") (setq dir "~"))
    (if newone
    (progn
      (sit-for 2)
      (insert (concat "cd " dir))
      (comint-send-input)))))

This lets me log in as the user using sudo to the specified computer.
But I don't have that that user's environment.  I *think* what I need is the 
option "-i" or "--login" to the command sudo.  But I can't figure how to get it 
in there.

Is this possible?  Is this what I even need?

Any input appreciated.
thanks!
tom


_______________________________________________
Tramp-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/tramp-devel

Reply via email to