PuTTY ssh authentication

PuTTY ssh authentication

Spread the love

All this variety of functionality ultimately boiled down to three main operations:

put the file to disk;

pick up a file from the disk;

run the program with parameters.

Practice

After a little exploring the PuTTY source code, we simply added several ESC sequences followed by data processing in the same way as the built-in printing function using the already established connection to the server.

Doing the bells and whistles in the form of implementing the Z-modem protocol was considered unnecessary and very difficult, since it was required to connect additional third-party libraries to the program, and on the server side also keep the programs up-to-date for working with this protocol. As practice has shown, on different platforms and versions of operating systems, these programs behave differently. Someone throws something on the screen, someone does not understand some keys.

Our implementation of the command and data transfer protocol ultimately resulted in linear data transfer over an already established communication channel.

How all this is implemented in practice:

The data exchange protocol looks quite simple – an ESC sequence is sent first, by which the PuTTY mode of operation is switched, in which all data is no longer on the screen, but left without on-screen processing. After that, either the file name or the command to start is sent. Next comes the file body. And at the end the parcel ends with the escape character ESC.

When sending or receiving a file, you must avoid getting into the stream of non-printable characters due to the fact that these characters can be interpreted by telnet or ssh servers as some kind of control characters and may not be transmitted. Also, a symbol with code 0 is not transmitted. A symbol with code 27 is a sign of the end of the stream, in which PuTTY returns to normal operation. For these characters, on the fly they are converted to HEX-format with the classic “/” before the number (for example, “/ AF”). Thus, the volume of transmitted data increases, but its loss and distortion does not occur.