{"id":2304,"date":"2022-03-22T15:43:31","date_gmt":"2022-03-22T10:13:31","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=2304"},"modified":"2022-03-22T15:43:39","modified_gmt":"2022-03-22T10:13:39","slug":"connecting-to-an-ftp-server-with-lftp","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/connecting-to-an-ftp-server-with-lftp\/","title":{"rendered":"Connecting to an FTP Server with LFTP"},"content":{"rendered":"<p>Date Posted: 31-01-2018<\/p>\n<p>In this Post we will explain How to Setup lftp &#8211; A Simple Command Line FTP Program.<\/p>\n<p>This article is about Lftp and how we can install Lftp in our Linux Operating System. Lftp is a command line based File Transfer Software also known as FTP Client.<\/p>\n<p><strong>Installing Lftp<\/strong><\/p>\n<p><strong>On Ubuntu<\/strong><\/p>\n<p>In Ubuntu&nbsp; and its derivatives, we can install lftp using&nbsp;apt&nbsp;manager. So, to install it, we&#8217;ll need to run the following commands in a shell or a terminal under sudo privilege.<\/p>\n<p>$ sudo apt-get install lftp<\/p>\n<p><strong>On CentOS\/Fedora\/RHEL<\/strong><\/p>\n<p>As lftp is also available in the repository of Fedora, CentOS and RHEL, we can use&nbsp;yum&nbsp;manager to install it.<\/p>\n<p>$ sudo yum install lftp<\/p>\n<p><strong>Connecting to your FTP server<\/strong><\/p>\n<p>To login to a ftp server or sftp server,&nbsp;make sure you know your FTP username and your server hostname. Once you have those you can simply connect to your FTP server by running:<\/p>\n<p>$ lftp ftp:\/\/username@hostname<\/p>\n<p><strong>Navigation<\/strong><\/p>\n<p>We can use&nbsp;&#8216;ls&#8217;&nbsp;to list files and directories,&nbsp;&#8216;cd&#8217;&nbsp;to enter into a&nbsp;directory.<\/p>\n<p><strong>Uploading and Download Files<\/strong><\/p>\n<p><strong>Pget command<\/strong><\/p>\n<p>We can use&nbsp;pget&nbsp;for downloading files from the remote server.<\/p>\n<p>$ pget file_from_server.txt<\/p>\n<p><strong>Put command<\/strong><\/p>\n<p>We can use&nbsp;put&nbsp;for uploading files to the remote server.<\/p>\n<p>$ put file_from_workspace_file.txt<\/p>\n<p><strong>Reverse mirroring of directory<\/strong><\/p>\n<p>If we want to mirror entire directory to the server, we will use reverse mirror command.<\/p>\n<p>lftp user@ip:~&gt; mirror -R<\/p>\n<p>This is used to copy local directory contenets to the server.<\/p>\n<p><strong>Exiting the shell<\/strong><\/p>\n<p>Bye command is used to exit from the lftp shell<\/p>\n<p><strong>Using LFTP commands as part of the script<\/strong><\/p>\n<p>After we exited the LFTP, we can use above commands without logging onto ftp server. That way you can embed it into bash script.<\/p>\n<p>$ lftp -e &#8216;mirror \/home\/user\/ \/home\/user\/Videos\/&#8217; -u user,password ftp:\/\/ip<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Date Posted: 31-01-2018 In this Post we will explain How to Setup lftp &#8211; A Simple Command Line FTP Program. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[],"class_list":["post-2304","post","type-post","status-publish","format-standard","hentry","category-web-architecture","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-Ba","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2304","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=2304"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2304\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=2304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=2304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=2304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}