{"id":4065,"date":"2012-01-06T12:31:02","date_gmt":"2012-01-06T17:31:02","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=4065"},"modified":"2013-10-22T09:01:49","modified_gmt":"2013-10-22T14:01:49","slug":"oracle-linux-5-5-setup-vsftp-server","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=4065","title":{"rendered":"Oracle Linux 5.5: Setup vsftp Server"},"content":{"rendered":"<div class='toc wptoc'>\n<h2>Contents<\/h2>\n<ol class='toc-odd level-1'>\n\t<li>\n\t\t<a href=\"#Setup_yum_Repository\">Setup yum Repository<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Install_vsftpd\">Install vsftpd<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Configure_vsftpd\">Configure vsftpd<\/a>\n\t\t<ol class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Open_ports\">Open ports<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Configure_SELinux_to_Allow_FTP_Traffic\">Configure SELinux to Allow FTP Traffic<\/a>\n\t\t\t<\/li>\n\t\t<\/ol>\n\t<li>\n\t\t<a href=\"#Startstoprestart_Service\">Start\/stop\/restart Service<\/a>\n\t\t<ol class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#View_Log\">View Log<\/a>\n\t\t\t<\/li>\n\t\t<\/ol>\n\t<li>\n\t\t<a href=\"#Enable_SFTP_for_vsFTP\">Enable SFTP for vsFTP<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Issues\">Issues<\/a>\n\t\t<ol class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#oops_chroot\">500 oops chroot<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Access_from_Windows_7_FTP_Client\">Access from Windows 7 FTP Client<\/a>\n\t\t\t<\/li>\n\t\t<\/ol>\n\t<li>\n\t\t<a href=\"#References\">References<\/a>\n\t<\/li>\n<\/ol>\n<\/ol>\n<\/div>\n<div class='wptoc-end'>&nbsp;<\/div>\n<span id=\"Setup_yum_Repository\"><h2>Setup yum Repository<\/h2><\/span>\n<p>* See this <a href=\"?p=3919\">post <\/a>to setup yum repository if it&#8217;s not already done.<\/p>\n<span id=\"Install_vsftpd\"><h2>Install vsftpd<\/h2><\/span>\n<pre lang=\"bash\">\r\nsu -\r\nyum install vsftpd\r\n<\/pre>\n<span id=\"Configure_vsftpd\"><h2>Configure vsftpd<\/h2><\/span>\n<p>* Config file is: <em>\/etc\/vsftpd\/vsftpd.conf<\/em><br \/>\n* Append to default <em>vsftpd.conf<\/em> file:<\/p>\n<pre lang=\"bash\">\r\n# Make sure chroot jail is turned off. This is the default\r\nchroot_local_user=NO\r\n\r\n# Turn on passive ports\r\npasv_enable=YES\r\npasv_min_port=11000\r\npasv_max_port=11010\r\n<\/pre>\n<span id=\"Open_ports\"><h3>Open ports<\/h3><\/span>\n<p>* Add to <em>\/etc\/sysconfig\/iptables<\/em> immediately under <em>&#8211;dport 22<\/em> entry:<\/p>\n<pre lang=\"bash\">\r\n-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT # This opens up port 21\r\n-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT # This opens up port 22 for sftp\r\n-A RH-Firewall-1-INPUT -p tcp --dport 11000:11010 -j ACCEPT # This opens up passive ports\r\n<\/pre>\n<span id=\"Configure_SELinux_to_Allow_FTP_Traffic\"><h3>Configure SELinux to Allow FTP Traffic<\/h3><\/span>\n<p>* Check that to see if SELINUX is enabled in <em>\/etc\/selinux\/config<\/em> file<\/p>\n<pre lang=\"bash\">\r\nSELINUX=enforcing\r\n#SELINUX=disabled\r\n<\/pre>\n<p>* If SELinux is enforced, you need to set one of the following: <\/p>\n<pre lang=\"bash\">\r\nsetsebool -P allow_ftpd_full_access 1 \r\nor \r\nsetsebool -P ftp_home_dir 1\r\n<\/pre>\n<span id=\"Startstoprestart_Service\"><h2>Start\/stop\/restart Service<\/h2><\/span>\n<pre lang=\"bash\">\r\n# Enable ftp to user home directory (SELinux only)\r\nsetsebool -P ftp_home_dir 1\r\n\r\n# Setup autostart\r\nchkconfig vsftpd on\r\n\r\n# Start\r\nservice vsftpd start\r\n\r\n# Stop\r\nservice vsftpd stop\r\n\r\n# Restart\r\nservice vsftpd restart\r\n\r\n# Check port 21 status\r\nnetstat -tulpn |grep :21\r\n<\/pre>\n<span id=\"View_Log\"><h3>View Log<\/h3><\/span>\n<p>* Log file is in \/var\/log directory<\/p>\n<pre lang=\"bash\">\r\ntail -f \/var\/log\/xferlog\r\n<\/pre>\n<span id=\"Enable_SFTP_for_vsFTP\"><h2>Enable SFTP for vsFTP<\/h2><\/span>\n<p>* Generate a new certificate<\/p>\n<pre lang=\"bash\">\r\nopenssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout \/etc\/vsftpd\/vsftpd.pem -out \/etc\/vsftpd\/vsftpd.pem\r\n\r\n[root@ftp01 vsftpd]# openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout \/etc\/vsftpd\/vsftpd.pem -out \/etc\/vsftpd\/vsftpd.pem\r\nGenerating a 1024 bit RSA private key\r\n.++++++\r\n..........++++++\r\nwriting new private key to '\/etc\/vsftpd\/vsftpd.pem'\r\n-----\r\nYou are about to be asked to enter information that will be incorporated\r\ninto your certificate request.\r\nWhat you are about to enter is what is called a Distinguished Name or a DN.\r\nThere are quite a few fields but you can leave some blank\r\nFor some fields there will be a default value,\r\nIf you enter '.', the field will be left blank.\r\n-----\r\nCountry Name (2 letter code) [GB]:US\r\nState or Province Name (full name) [Berkshire]:Virginia\r\nLocality Name (eg, city) [Newbury]:Reston\r\nOrganization Name (eg, company) [My Company Ltd]:Example\r\nOrganizational Unit Name (eg, section) []:Example\r\nCommon Name (eg, your name or your server's hostname) []:ftp01\r\nEmail Address []:\r\n<\/pre>\n<p>* chmod key file:<\/p>\n<pre lang=\"bash\">\r\nchmod 600 vsftpd.pem\r\n<\/pre>\n<p>* Modify <em>vsftpd.conf<\/em> to include:<\/p>\n<pre>\r\nssl_enable=YES\r\nallow_anon_ssl=NO\r\nforce_local_data_ssl=NO\r\nforce_local_logins_ssl=NO # Set to YES to force sftp\r\nssl_tlsv1=YES\r\nssl_sslv2=NO\r\nssl_sslv3=NO\r\nrsa_cert_file=\/etc\/vsftpd\/vsftpd.pem\r\n<\/pre>\n<p>* Restart vsftpd service:<\/p>\n<pre lang=\"bash\">\r\nservice vsftpd restart\r\n<\/pre>\n<p>* Test sftp connection using <em>WinSCP<\/em><br \/>\n&#8211; Protocol: sftp<br \/>\n&#8211; Port: 22<\/p>\n<span id=\"\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/10\/vsftpd_sftp_login_withSCP.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/10\/vsftpd_sftp_login_withSCP-300x264.jpg\" alt=\"\" title=\"vsftpd_sftp_login_withSCP\" width=\"300\" height=\"264\" class=\"aligncenter size-medium wp-image-9330\" srcset=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/10\/vsftpd_sftp_login_withSCP-300x264.jpg 300w, https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2013\/10\/vsftpd_sftp_login_withSCP.jpg 516w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/h6><\/span>\n<span id=\"Issues\"><h2>Issues<\/h2><\/span>\n<span id=\"oops_chroot\"><h3>500 oops chroot<\/h3><\/span>\n<p>* In SELinux, you need to set one of the following: <\/p>\n<pre lang=\"bash\">\r\nsetsebool -P allow_ftpd_full_access 1\r\nor\r\nsetsebool -P ftp_home_dir 1\r\n<\/pre>\n<span id=\"Access_from_Windows_7_FTP_Client\"><h3>Access from Windows 7 FTP Client<\/h3><\/span>\n<p>* ftp command line utility didn&#8217;t work for me<\/p>\n<span id=\"_1\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2012\/01\/win7_ftp_client.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2012\/01\/win7_ftp_client-300x151.jpg\" alt=\"\" title=\"win7_ftp_client\" width=\"300\" height=\"151\" class=\"aligncenter size-medium wp-image-4069\" srcset=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2012\/01\/win7_ftp_client-300x151.jpg 300w, https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2012\/01\/win7_ftp_client.jpg 672w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/h6><\/span>\n<p>* Use File Explorer to access vsftp server instead:<br \/>\n&#8211; Open File Explorer<br \/>\n&#8211; Type into addressbox: ftp:\/\/wxbox<br \/>\n&#8211; Enter username and password<\/p>\n<span id=\"_2\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2012\/01\/win7_ftp_client2.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2012\/01\/win7_ftp_client2-300x209.jpg\" alt=\"\" title=\"win7_ftp_client2\" width=\"300\" height=\"209\" class=\"aligncenter size-medium wp-image-4070\" srcset=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2012\/01\/win7_ftp_client2-300x209.jpg 300w, https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2012\/01\/win7_ftp_client2.jpg 494w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/h6><\/span>\n<span id=\"References\"><h2>References<\/h2><\/span>\n<p>* <a href=\"https:\/\/security.appspot.com\/vsftpd\/vsftpd_conf.html\">VSFTPD.CONF<\/a><br \/>\n* <a href=\"http:\/\/www.cyberciti.biz\/tips\/rhel-fedora-centos-vsftpd-installation.html\">Red Hat \/ CentOS VSFTPD FTP Server Configuration<\/a><br \/>\n* <a href=\"http:\/\/forums.fedoraforum.org\/showthread.php?p=1262590\">Common vsftp problems and likely solutions<\/a><br \/>\n* <a href=\"http:\/\/wiki.vpslink.com\/Configuring_vsftpd_for_secure_connections_%28TLS\/SSL\/SFTP%29\">Configuring vsftpd for secure connections (TLS\/SSL\/SFTP)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setup yum Repository * See this post to setup yum repository if it&#8217;s not already done. Install vsftpd su &#8211; yum install vsftpd Configure vsftpd * Config file is: \/etc\/vsftpd\/vsftpd.conf * Append to default vsftpd.conf file: # Make sure chroot &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=4065\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_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}},"categories":[61],"tags":[],"class_list":["post-4065","post","type-post","status-publish","format-standard","hentry","category-linux"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-13z","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/4065","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4065"}],"version-history":[{"count":23,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/4065\/revisions"}],"predecessor-version":[{"id":4101,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/4065\/revisions\/4101"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4065"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4065"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4065"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}