phpsshsftpdeprecatedcentos5

How to perform SFTP operations using PHP after disabling deprecated ciphers on CentOS5?


I have PHP code for SFTP operations which is working fine on a CentOS5 machine currently. After disabling the following deprecated ciphers, it stopped working.

Here is the list of ciphers

Key Exchange: diffie-hellman-group1-sha1 Ciphers: arcfour256, arcfour128, 3DES-cbc, blowfish-cbc, cast128-cbc, arcfour

Here is the current code snippet

$connection = ssh2_connect('ftp_url', 'ftp_port');

Solution

  • This worked. This approach actually enforces code to use specified ciphers

    $methods = array(
             'hostkey'                 => 'ssh-rsa,ssh-dss',
             'client_to_server'        => array(
                     'crypt'  => 'aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc',
                     'comp'   => 'none'
             ),
             'server_to_client'        => array(
                     'crypt'  => 'aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc',
                     'comp'   => 'none'
             )
    );
    
    $connection = ssh2_connect( 'ftp_url', 'ftp_port', $methods );