{"id":888,"date":"2012-08-09T17:09:14","date_gmt":"2012-08-09T15:09:14","guid":{"rendered":"http:\/\/saladtomatonion.com\/blog\/?p=888"},"modified":"2013-01-07T16:27:58","modified_gmt":"2013-01-07T14:27:58","slug":"faire-du-ftp-a-travers-un-proxy-en-python","status":"publish","type":"post","link":"https:\/\/saladtomatonion.com\/blog\/2012\/08\/09\/faire-du-ftp-a-travers-un-proxy-en-python\/","title":{"rendered":"Faire du FTP \u00e0 travers un proxy en python"},"content":{"rendered":"<p>Aujourd&rsquo;hui, on transf\u00e8re des fichiers par un protocole bien nomm\u00e9! J&rsquo;ai voulu utiliser la biblioth\u00e8que python <code><a href=\"http:\/\/docs.python.org\/library\/ftplib.html\" target=\"_blank\">ftplib<\/a><\/code> pour joindre un serveur externe \u00e0 mon travail, et voici comment j&rsquo;ai fait.<\/p>\n<p><!--more-->Nous avons un serveur mandataire pour le protocole FTP au sein de notre entreprise, disons qu&rsquo;il s&rsquo;appelle <code>ftp-proxy<\/code> et qu&rsquo;il utilise le port 2100.<\/p>\n<p>La s\u00e9quence \u00e0 suivre pour se connecter au serveur externe n&rsquo;est pas tr\u00e8s intuitive, mais fonctionne finalement.<\/p>\n<blockquote><p>Attention, il faut penser \u00e0 bien indiquer le num\u00e9ro de port au moment de passer le nom du serveur externe, m\u00eame quand il s&rsquo;agit du port par d\u00e9faut (21)<\/p><\/blockquote>\n<pre name=\"code\" class=\"py:nogutter:nocontrols\">import ftplib\r\nftp = ftplib.FTP()\r\nftp.connect('ftp-proxy',2100)\r\nftp.login('mon_user@ftp-externe.domaine.com:21','motdepasse')<\/pre>\n<p>La magie, c&rsquo;est de passer l&rsquo;identifiant complet (nom@serveur) en tant que login pour le serveur mandataire.<\/p>\n<p>Cependant il est possible, mais je n&rsquo;en suis pas s\u00fbr, que certains types de proxy ftp n&rsquo;acceptent pas ce genre de transaction. Qui pourrait confirmer ou infirmer?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Aujourd&rsquo;hui, on transf\u00e8re des fichiers par un protocole bien nomm\u00e9! J&rsquo;ai voulu utiliser la biblioth\u00e8que python ftplib pour joindre un serveur externe \u00e0 mon travail, et voici comment j&rsquo;ai fait.<\/p>\n","protected":false},"author":2,"featured_media":887,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[4],"tags":[218,21,38],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/saladtomatonion.com\/blog\/wp-content\/uploads\/2012\/08\/dossier-ftp-icone-3664-48.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/saladtomatonion.com\/blog\/wp-json\/wp\/v2\/posts\/888"}],"collection":[{"href":"https:\/\/saladtomatonion.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/saladtomatonion.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/saladtomatonion.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/saladtomatonion.com\/blog\/wp-json\/wp\/v2\/comments?post=888"}],"version-history":[{"count":15,"href":"https:\/\/saladtomatonion.com\/blog\/wp-json\/wp\/v2\/posts\/888\/revisions"}],"predecessor-version":[{"id":914,"href":"https:\/\/saladtomatonion.com\/blog\/wp-json\/wp\/v2\/posts\/888\/revisions\/914"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/saladtomatonion.com\/blog\/wp-json\/wp\/v2\/media\/887"}],"wp:attachment":[{"href":"https:\/\/saladtomatonion.com\/blog\/wp-json\/wp\/v2\/media?parent=888"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/saladtomatonion.com\/blog\/wp-json\/wp\/v2\/categories?post=888"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/saladtomatonion.com\/blog\/wp-json\/wp\/v2\/tags?post=888"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}