2012-05-14 32 views
3

我使用paramiko通過ssh連接到遠程服務器。使用公鑰進行身份驗證時,性能很慢(約90秒)。以下是相關的日誌輸出:與paramiko緩慢的公鑰認證

2012-05-14 17:37:21,378 Ciphers agreed: local=aes128-ctr, remote=aes128-ctr 
2012-05-14 17:37:21,378 using kex diffie-hellman-group1-sha1; server key type ssh-rsa; cipher: local aes128-ctr, remote aes128-ctr; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none 
2012-05-14 17:37:21,481 Switch to new keys ... 
2012-05-14 17:37:21,483 Adding ssh-rsa host key for 10.12.34.56: 8a05c68a0707a9fad19290c22542a338 
2012-05-14 17:37:21,485 Trying discovered key 3793c7b9c500f52c12e190e92e21713f in /home/david/.ssh/id_rsa 
2012-05-14 17:37:21,513 userauth is OK 
2012-05-14 17:38:54,370 Authentication (publickey) successful! 

請注意最後兩行日誌輸出之間的延遲。當使用ssh從同一用戶和遠程服務器的命令行進行連接時,連接是即時的。任何想法是什麼造成了延遲?

回答

0

經過大量的實驗後,延遲似乎與密鑰的長度有關。我使用的第一個密鑰是4096位。當我切換到一個較短(2048位)的密鑰時,認證所需的時間大幅度減少(< 2秒)。

3

pycrypto>=2.5是非常緩慢的。降級到pycrypto==2.4.1後,我看到了25倍的提升。

+0

這是唯一能夠幫助我加速Fabric(使用pycrypto)的東西。大改進。 –