Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do I find the spec for scp -t?

Tags:

scp

So I have discovered I can do the following with scp via stdin:

Directory creation

scp -tr .
stdin -> D0755 0 <directory_name>
stdin -> \x00

File writing

scp -tr .
stdin -> C<filemode, eg. 0744> <file_size_in_bytes> <filename>
stdin -> actual file bytes
stdin -> \x00

In the man pages I can't find any mention of this, nor have I had luck with googling. Where do I find the spec for these various commands: file creation, directory creation? What else can I do? I'm curious where this is defined. I'm struggling to find where I even found this code initially. Why is there no mention of the -t flag in the scp man page?

like image 848
James Avatar asked Jun 01 '18 06:06

James


1 Answers

scp transfers files by opening an SSH connection to a remote server and invoking another copy of scp on the remote system. The two scp instances communicate through a simple protocol; one instance sends commands and file data; the other instance acts on the commands to store the files on its local system.

The -t option tells scp that it was invoked by another scp instance and that it'll be receiving files. There is another option -f which tells scp that it was invoked by another instance and should send files.

You'd have to ask the OpenSSH developers why the options aren't documented. One might presume that it's because they're not intended for use by humans and so not really part of the user interface.

The best online descriptions of the SCP protocol that I know of are:

  • How the SCP protocol works
  • Ruby net-scp source code
  • OpenSSH scp source code
like image 155
Kenster Avatar answered Nov 03 '22 00:11

Kenster