tramp-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug: scp confused by single quotes in ControlPath


From: Daniel Kessler
Subject: Bug: scp confused by single quotes in ControlPath
Date: Wed, 11 May 2022 12:40:14 -0400

Dear Tramp Developers,

Currently, if I connect to a remote server using the scp method (e.g., /scp:server:/home), I am prompted for my username, password, and passcode (I use 2FA). If I open/edit small files, things work nicely, i.e., I am not prompted for my username, password, or passcode again. This is because I have tramp-use-ssh-controlmaster-options set to t and tramp-ssh-controlmaster-options is nil, so tramp "auto-chooses" appropriate ControlMaster options. 

However, if I open or save a large file, I am re-prompted for my passcode (presumably it uses the cached password I already provided). This is odd because tramp should be using the ControlMaster socket it has already established, and annoying because I have to repeat the two factor authentication process over and over.

If I connect using ssh in the first place (e.g., /ssh:server:/home), then I am only prompted for my credentials on initial connection and tramp appropriately uses the ControlMaster socket for all subsequent operations. However, for very large files scp is much more performant so I'd rather not force tramp to use inline methods.

I believe I have pinpointed this to the way ControlPath is specified throughout the file tramp-sh.el. Specifically, ControlPath is specified in a manner that includes hard quotes. This is present in both comments and code in the current master branch, e.g.,

		  (setq tramp-ssh-controlmaster-options
			(concat tramp-ssh-controlmaster-options
				" -o ControlPath='tramp.%%C'"))


When the connection is initially established, it starts a shell process and then performs ssh there, and so the shell consumes the hard quotes. However, when external methods are used (e.g., tramp-do-copy-or-rename-file-out-of-band), the scp program is invoked directly (i.e., without going through a shell), and so scp is looking for a ControlPath file that includes a literal single quote (which of course doesn't exist). Because it can't find the ControlPath, it has to establish a fresh ssh connection, which involves some overhead and thus requires me to provide my credentials again.

I was able to fix this by manually setting tramp-ssh-control-master-options as:
  (setq tramp-ssh-controlmaster-options
        "-o ControlMaster=auto -o ControlPath=tramp.%%C -o ControlPersist=no")

However, I wonder if the hard quotes in tramp-sh.el are truly required: are there especially problematic characters that %C might expand to that would require quoting? If so, it might be necessary to modify the options on-the-fly so that the quotes are present when being used in a call that goes via the shell and absent when being passed directly to a (non-shell) process.

Thanks for your consideration, and please let me know if there are any further details I should provide.

Sincerely,
Dan Kessler


--
Dan Kessler
Student, PhD in Statistics
University of Michigan, Ann Arbor
kesslerd@umich.edu
+1 734.726.0541
www.dankessler.me

reply via email to

[Prev in Thread] Current Thread [Next in Thread]