Почему linux распознает файл .cs C # как исходный файл C ++?

Вы не создаете ключ, используемый aes при использовании ssh-keygen . Поскольку aes является симметричным шифром , его ключи не приходят попарно. На обоих концах связи используется один и тот же ключ.

Ключ, созданный ssh-keygen, использует криптографию с открытым ключом для аутентификации. Из руководства ssh-keygen :

 ssh-keygen generates, manages and converts authentication keys for
 ssh(1).  ssh-keygen can create RSA keys for use by SSH protocol version 1
 and DSA, ECDSA, Ed25519 or RSA keys for use by SSH protocol version 2.

Из руководства ssh :

 Public key authentication works as follows: The scheme is based on
 public-key cryptography, using cryptosystems where encryption and
 decryption are done using separate keys, and it is unfeasible to derive
 the decryption key from the encryption key.  The idea is that each user
 creates a public/private key pair for authentication purposes.  The
 server knows the public key, and only the user knows the private key.
 ssh implements public key authentication protocol automatically, using
 one of the DSA, ECDSA, Ed25519 or RSA algorithms.

Проблема криптографии с открытым ключом в том, что она довольно медленная. Симметричная криптография ключей намного быстрее и используется ssh для фактической передачи данных. Ключ, используемый для симметричной криптографии, генерируется на лету после установления соединения (цитата из руководства sshd ):

 For protocol 2, forward security is provided through a Diffie-Hellman key
 agreement.  This key agreement results in a shared session key.  The rest
 of the session is encrypted using a symmetric cipher, currently 128-bit
 AES, Blowfish, 3DES, CAST128, Arcfour, 192-bit AES, or 256-bit AES.  The
 client selects the encryption algorithm to use from those offered by the
 server.  Additionally, session integrity is provided through a
 cryptographic message authentication code (hmac-md5, hmac-sha1, umac-64,
 umac-128, hmac-ripemd160, hmac-sha2-256 or hmac-sha2-512).

Если вы хотите использовать aes256-cbc , вы должны указать его в командной строке с помощью параметра -c, в его самом основном виде это будет выглядеть следующим образом:

$ ssh -c aes256-cbc user@host

Вы также можете указать предпочтительный выбор шифров в ssh _ config , используя список, разделенный запятыми. Однако не рекомендуется тычать с дефолтами, поскольку это лучше оставить на усмотрение экспертов. Есть много соображений и многолетний опыт, которые перешли к выбору значений по умолчанию разработчиками OpenSSH.

2
07.06.2018, 05:52
1 ответ

Eche un vistazo a la página del manual para el comando file:

$ man file

...

file tests each argument in an attempt to classify it. There are three sets of tests, performed in this order: filesystem tests, magic tests, and language tests. The first test that succeeds causes the file type to be printed.

Es la tercera prueba(pruebas de idioma)que realiza fileque clasifica este archivo como un archivo C++.

Once file has determined the character set used in a text-type file, it will attempt to determine in what language the file is written. The language tests look for particular strings (cf. #include ) that can appear anywhere in the first few blocks of a file. For example, the keyword.br indicates that the file is most likely a troff(1) input file, just as the keyword struct indicates a C program. These tests are less reliable than the previous two groups, so they are performed last. The language test routines also test for some miscellany (such as tar(1) archives).

Los archivos C #se asemejan más a los archivos C++, por lo que file"supone" que el archivo.cs es un archivo C++.

Ejemplo

$ more blah.cs
// A Hello World! program in C#.
using System;
namespace HelloWorld
{
    class Hello
    {
        static void Main()
        {
            Console.WriteLine("Hello World!");

            // Keep the console window open in debug mode.
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
    }
}

Comprobación confile:

$ file blah.cs
blah.cs: ASCII C++ program text
2
27.01.2020, 22:09

Теги

Похожие вопросы