Skip to content

add aes128-gcm and aes256-gcm support - #2157

Closed
cheng0214 wants to merge 2 commits into
paramiko:mainfrom
cheng0214:main
Closed

cheng0214 wants to merge 2 commits into
paramiko:mainfrom
cheng0214:main

Conversation

@cheng0214

Copy link
Copy Markdown

Add aes128-gcm and aes256-gcm support for paramiko.
solve this #1394

@bskinn

bskinn commented Dec 17, 2022

Copy link
Copy Markdown
Contributor

Flagging this to include/consider in the key/auth rewrite of #387, slated for after the modernization effort to, e.g., drop Python 2 and older 3.x.

Thanks for the report, @cheng0214!

Comment thread paramiko/transport.py Resolved
@magsen

magsen commented May 31, 2023

Copy link
Copy Markdown

Tested and works for a server with only aes128-gcm and aes256-gcm support, using fabric and applying patched paramiko with this PR.

@tristanlatr

Copy link
Copy Markdown

Do you have an ETA of the lading of this patch into stable paramiko releases?

@cmason3

cmason3 commented Oct 3, 2023

Copy link
Copy Markdown
Contributor

Any chance this will be merged for the 3.4.0 release as Paramiko is the only reason I still have to have non-AEAD ciphers enabled on hundreds of devices?

@yannislionis

Copy link
Copy Markdown

Also keen to use this when merged!

@cmason3

cmason3 commented Dec 4, 2023

Copy link
Copy Markdown
Contributor

Any view on whether this will make it into 3.4.0?

spandey-kyriba added a commit to spandey-kyriba/paramiko that referenced this pull request Dec 28, 2023
spandey-kyriba added a commit to spandey-kyriba/paramiko that referenced this pull request Dec 28, 2023
@cmason3

cmason3 commented Jan 9, 2024

Copy link
Copy Markdown
Contributor

Is this pull request likely to make it into a Paramiko release any time soon?

@bskinn

bskinn commented Jan 11, 2024

Copy link
Copy Markdown
Contributor

Unfortunately uncertain, @cmason3. bitprophet has needed to turn his focus elsewhere for a while now, and I don't know when he's going to be able to return attention to paramiko for other than critical security updates, like the Terrapin fix in 3.4.

ydnath added a commit to Juniper/paramiko that referenced this pull request Apr 8, 2024
@samskalicky

Copy link
Copy Markdown

+1 would really appreciate having aes256-gcm support. I just spent hours debugging the paramiko Incompatible ssh peer (no acceptable cyper) error. Eventually i stumbled upon the fact that my computer/server both were capable of the aes256-gcm cypher (I could manually ssh into the server) and it was just an issue with paramiko not supporting it.

It would be great to have an actual error message that says that explicitly: "Paramiko does not support aes256-gcm cypher chosen by handshake/server" or something to that effect.

@cmason3

cmason3 commented May 10, 2024

Copy link
Copy Markdown
Contributor

Is there anything the community can do to assist in getting AES/GCM support merged into Paramiko or it is dependent on a single person finding some time to review it and agree for it to be merged (whilst also deciding whether this is more important than the other issues and pull requests that are pending)?

@rayakurl

Copy link
Copy Markdown

Any ETA on this? I would like to use it.

@adiroiban

adiroiban commented May 30, 2024 •

Copy link
Copy Markdown

Thanks for the code from this PR

I think that what the "community" can do is:

  • Test the current code with various 3rd party servers
  • Review and and send feedback to the current code
  • Add automated tests to the code

In this way, if the PR is is good shape, it should be much easier to merge.


I did some initial testing with the code from this branch against a local OpenSSH and it looks good

The idea is to try to tranfer a larger file so that you can have all kind of paddings and IVs... in the case there are any errors in the code.

#
# A simple test to upload a file using paramiko, using ETM and GCM.
#
import os
from getpass import getpass

import paramiko


transport = paramiko.Transport(('localhost', 22))
options = transport.get_security_options()
options.digests = ('[email protected]',)
options.ciphers = ('[email protected]',)

# Do the connection.
transport.start_client()
print('Connected to {}'.format(transport.get_remote_server_key()))
print('Version local:{} remote:{}'.format(
    transport.local_version, transport.remote_version))
print('MAC local:{} remote:{}'.format(
    transport.local_mac, transport.remote_mac))
print('Ciphers local:{} remote:{}'.format(
    transport.local_cipher, transport.remote_cipher))
print('Compression local:{} remote:{}'.format(
    transport.local_compression, transport.remote_compression))

# Do the authentication.
user = os.environ.get('USER', 'NO-USER-FOUND')
password = getpass(f'Pass for {user}: ')
transport.auth_password(user, password)

# Start the SFTP session.
sftp_client = transport.open_sftp_client()

print(sftp_client.listdir('/tmp'))
sftp_client.put('LICENSE', '/tmp/LICENSE')

sftp_client.close()
transport.close()

the result

Connected to PKey(alg=ED25519, bits=256, fp=SHA256:ynyyc2995Z+yW/kguyRBiluk9ysRAg3kFtrQ7KW136o)
Version local:SSH-2.0-paramiko_3.4.0 remote:SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13
MAC local:[email protected] remote:[email protected]
Ciphers local:[email protected] remote:[email protected]
Compression local:none remote:none

@cmason3

cmason3 commented Sep 5, 2024

Copy link
Copy Markdown
Contributor

I don't suppose there is any progress on merging AES GCM support into Paramiko? I can see Juniper have now forked Paramiko and have applied the patch themselves (https://github.com/Juniper/paramiko), so it is actively being used if that helps? However, this is really bad as they don't seem to be keeping their fork up to date with this one, so people are potentially running code that has unpatched security issues.

@adiroiban

Copy link
Copy Markdown

I expect that there are other projects that forked paramiko.

I am using paramiko just to support testing our infrastructure ... so I ended up with a fork.

@tuxmaster5000

Copy link
Copy Markdown

It looks like the patch is out of sync with the master :(

checking file paramiko/packet.py
Hunk #1 succeeded at 115 (offset 1 line).
Hunk #2 succeeded at 158 (offset 7 lines).
Hunk #3 succeeded at 174 (offset 7 lines).
Hunk #4 succeeded at 191 (offset 7 lines).
Hunk #5 succeeded at 208 (offset 7 lines).
Hunk #6 succeeded at 400 (offset 1 line).
Hunk #7 succeeded at 443 (offset 1 line).
Hunk #8 succeeded at 494 (offset 4 lines).
Hunk #9 succeeded at 513 (offset 4 lines).
Hunk #10 succeeded at 556 (offset 4 lines).
Hunk #11 succeeded at 679 (offset 4 lines).
checking file paramiko/transport.py
Hunk #1 succeeded at 30 (offset -1 lines).
Hunk #2 succeeded at 184 (offset 20 lines).
Hunk #3 FAILED at 224.
Hunk #4 succeeded at 2046 (offset 49 lines).
Hunk #5 succeeded at 2718 with fuzz 1 (offset 106 lines).
Hunk #6 succeeded at 2753 (offset 106 lines).
Hunk #7 succeeded at 2798 with fuzz 1 (offset 120 lines).
Hunk #8 succeeded at 2834 (offset 120 lines).
1 out of 8 hunks FAILED

@cmason3

cmason3 commented Sep 11, 2024

Copy link
Copy Markdown
Contributor

I am not sure if this was the correct way of doing this in Git, but I have created PR #2444 which duplicates this PR, but will now cleanly merge on top of main to add support for AES256/GCM and AES128/GCM.

@bitprophet

Copy link
Copy Markdown
Member

Rolling this into #2444 - and don't worry, if we end up merging this, will give due credit 🙏🏻

@bitprophet bitprophet closed this Sep 14, 2024
bitprophet added a commit that referenced this pull request Sep 15, 2024
bitprophet added a commit that referenced this pull request Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.