Timo Lilja
2005-Jul-11 21:47 UTC
Feature suggestion: sftp over ssh client in a single connection
It has always bugged me that if I want to use a shell and perform some file transfers in a single host I have to take two SSH connections: one for the shell via ssh(1) and one for the file transfer via sftp(1). Some graphical SSH clients can perform sftp operations and ssh shell access in a single connection by using SSH2 protocol's support for multiple channels. So I hacked my openssh client to start the sftp prompt when the escape sequence '~S' has been entered. The sftp session is implemented by opening another channel into the same connection. After the user has quit the sftp prompt, the client returns to the original ssh with possible shell prompt or whatever. The actual implementation is rather simple: The client basically forks another process and runs a slightly modified version of the sftp interactive_loop(). A little bit of hacking is needed so that the primary ssh2_channel won't take the input/output while the sftp session is active. The forking ensures that clientloop.c's select(2) is performed normally so that the forwarded connections still work. I can provide the patches if needed but since I am not very familiar with the openssh code and not at all familiar with security related code I think that someone who knows what he/she is doing might do a better job ;-). -- Timo Lilja "It's a 106 miles to Chicago. We've got a full tank of gas, half a pack of cigarettes, it's dark, and we're wearing sunglasses."
Damien Miller
2005-Jul-12 11:19 UTC
Feature suggestion: sftp over ssh client in a single connection
Timo Lilja wrote:> It has always bugged me that if I want to use a shell and perform some > file transfers in a single host I have to take two SSH connections: > one for the shell via ssh(1) and one for the file transfer via > sftp(1).Already done, using session multiplexing. See "ControlMaster" and "ControlPath" in ssh_config(5). -d
Darren Tucker
2005-Jul-12 11:26 UTC
Feature suggestion: sftp over ssh client in a single connection
Timo Lilja wrote:> It has always bugged me that if I want to use a shell and perform some > file transfers in a single host I have to take two SSH connections: > one for the shell via ssh(1) and one for the file transfer via > sftp(1). Some graphical SSH clients can perform sftp operations and > ssh shell access in a single connection by using SSH2 protocol's > support for multiple channels.You can sftp and a shell over a single SSH connection with the ControlMaster/ControlPath feature: $ ssh -MS /tmp/sock sshserver $ sftp -o 'ControlPath /tmp/sock' sshserver (on the current development version you can do it more transparently with "ControlMaster auto").> So I hacked my openssh client to start the sftp prompt when the escape > sequence '~S' has been entered. The sftp session is implemented by > opening another channel into the same connection. After the user has > quit the sftp prompt, the client returns to the original ssh with > possible shell prompt or whatever.The above won't run sftp from an escape sequence, though. -- Darren Tucker (dtucker at zip.com.au) GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4 37C9 C982 80C7 8FF4 FA69 Good judgement comes with experience. Unfortunately, the experience usually comes from bad judgement.