当前位置:首页 » 文件管理 » 怎么指定ftp账号的目录

怎么指定ftp账号的目录

发布时间: 2023-10-13 11:18:39

⑴ 如何用我的电脑打开ftp地址

用自己的电脑打开FTP地址的具体操作如下:

⑵ FTP服务器 怎么根据用户登入名,跳转到相应目录下呢

那你就用vsftp,为什么偏要用leapftp 2.7.6 ?

是在linux上的vsfpt配置文件设置的。
目录是/etc/vsftpd/vsftpd.conf
把其中的chroor_local_user=YES 前面的*好去掉,然后重启vsftpd看看

⑶ 【重赏】IIS FTP单一用户单一目录设置

新建一个FTP站点,按提示一步步建立,选择“隔离用户”模式安装,在任一NTFS分区建一目录做为FTP站点的主目录,并在该文件夹内创建“LocalUser”文件夹,再在“LocalUser”文件夹内创建“Public”、“a1”、“a2”三个文件夹。
1、FTP站点必须是“隔离用户”模式;
2、必须在NTFS上建立FTP主目录;
3、FTP主目录下必须建立一个“LocalUser”文件夹;
4、在“LocalUser”文件夹下创建的用户主目录必须与用户名一致,“Public”除外。

⑷ linux下设置用户登录FTP服务器时,所在的目录

在vsftpd.conf这个文件里面的,local_enable=yes,首先要开启这个,然后用user add命令新建本地用户,然后把自家目录由/home,改为其他,要修改这个文件,/etc/passwd:

root:x:0:0:root:/root:/bin/bash

bin:x:1:1:bin:/bin:/sbin/nologin

daemon:x:2:2:daemon:/sbin:/sbin/nologin

desktop:x:80:80:desktop:/var/lib/menu/kde:/sbin/nologin

mengqc:x:500:500:mengqc:/home/mengqc:/bin/bash

如上所显示,找到你的本地用户,然后把/home后面的路径改了就可以,记得保存这个文件。这样FTP用户就可以用本地用户登录了,不改路径的话需要另外开启/home的访问权限,由于这个是敏感目录,所以个人并不推荐开启。

⑸ ftp的路径怎么设置

问一下,你是想做ftp上传下载么?

首先你需要安装一个ftp服务端程序,启动起来,然后下载一个ftp客户端程序,测试能不能连接,首先这一块儿需要测试通过。
代码ftp上传下载
2.1 上传代码:
import java.io.File;
import java.io.FileInputStream;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;

public class test {

private FTPClient ftp;
/**
*
* @param path 上传到ftp服务器哪个路径下
* @param addr 地址
* @param port 端口号
* @param username 用户名
* @param password 密码
* @return
* @throws Exception
*/
private boolean connect(String path,String addr,int port,String username,String password) throws Exception {
boolean result = false;
ftp = new FTPClient();
int reply;
ftp.connect(addr,port);
ftp.login(username,password);
ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
ftp.disconnect();
return result;
}
ftp.changeWorkingDirectory(path);
result = true;
return result;
}
/**
*
* @param file 上传的文件或文件夹
* @throws Exception
*/
private void upload(File file) throws Exception{
if(file.isDirectory()){
ftp.makeDirectory(file.getName());
ftp.changeWorkingDirectory(file.getName());
String[] files = file.list();
for (int i = 0; i < files.length; i++) {
File file1 = new File(file.getPath()+"\\"+files[i] );
if(file1.isDirectory()){
upload(file1);
ftp.changeToParentDirectory();
}else{
File file2 = new File(file.getPath()+"\\"+files[i]);
FileInputStream input = new FileInputStream(file2);
ftp.storeFile(file2.getName(), input);
input.close();
}
}
}else{
File file2 = new File(file.getPath());
FileInputStream input = new FileInputStream(file2);
ftp.storeFile(file2.getName(), input);
input.close();
}
}
public static void main(String[] args) throws Exception{
test t = new test();
t.connect("", "localhost", 21, "yhh", "yhhazr");
File file = new File("e:\\uploadify");
t.upload(file);
}
}
2.2 下载代码
这里没有用到filter,如果用filter就可以过滤想要的文件。

public class Ftp {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Ftp ftp = new Ftp();
String hostname = "www.strawberry.com";
Integer port = 21;
String username = "username";
String password = "password";
String remote = "/c.txt";
String local = "/home/tin/LeonChen/FTP/";
try {
ftp.connect(hostname, port, username, password);
System.out.println("接收状态:"+ftp.download(remote, local));
ftp.disconnect();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

private FTPClient ftpClient = new FTPClient();

/*
* * 连接到FTP服务器
* * @param hostname 主机名
* * @param port 端口
* * @param username 用户名
* * @param password 密码
* * @return 是否连接成功
* * @throws IOException
*/
private boolean connect(String hostname, int port, String username,
String password) throws IOException {
ftpClient.connect(hostname, port);
ftpClient.setControlEncoding("UTF-8");
if (FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) {
if (ftpClient.login(username, password)) {
return true;
}
}
disconnect();
return false;
}

/*
* 从FTP服务器上下载文件,支持断点续传,上传百分比汇报
*
* @param remote 远程文件路径
*
* @param local 本地文件路径
*
* @return 上传的状态
*
* @throws IOException
*/
public DownloadStatus download(String remote, String local)
throws IOException {
// 设置被动模式
ftpClient.enterLocalPassiveMode();
// 设置以二进制方式传输
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
DownloadStatus result;
// 检查远程文件是否存在
FTPFile[] files = ftpClient.listFiles(new String(remote
.getBytes("UTF-8"), "iso-8859-1"));
if (files.length != 1) {
System.out.println("远程文件不存在");
return DownloadStatus.Remote_File_Noexist;
}
long lRemoteSize = files[0].getSize();
String fildName = files[0].getName();
// 本地存在文件,进行断点下载
File f = new File(local+fildName);
if (f.exists()) {
long localSize = f.length();
if (localSize >= lRemoteSize) {
System.out.println("本地文件大于远程文件,下载中止");
return DownloadStatus.Local_Bigger_Remote;
}

// 进行断点续传,并记录状态
FileOutputStream out = new FileOutputStream(f, true);
ftpClient.setRestartOffset(localSize);
InputStream in = ftpClient.retrieveFileStream(new String(remote.getBytes("UTF-8"), "iso-8859-1"));
byte[] bytes = new byte[1024];
long step = lRemoteSize / 100;
long process = localSize / step;
int c;
while ((c = in.read(bytes)) != -1) {
out.write(bytes, 0, c);
localSize += c;
long nowProcess = localSize / step;
if (nowProcess > process) {
process = nowProcess;
if (process % 10 == 0)
System.out.println("下载进度:" + process);
// TODO 更新文件下载进度,值存放在process变量中
}
}
in.close();
out.close();
boolean isDo = ftpClient.completePendingCommand();
if (isDo) {
result = DownloadStatus.Download_From_Break_Success;
} else {
result = DownloadStatus.Download_From_Break_Failed;
}
} else {
OutputStream out = new FileOutputStream(f);
InputStream in = ftpClient.retrieveFileStream(new String(remote.getBytes("UTF-8"), "iso-8859-1"));
byte[] bytes = new byte[1024];
long step = lRemoteSize / 100;
long process = 0;
long localSize = 0L;
int c;
while ((c = in.read(bytes)) != -1) {
out.write(bytes, 0, c);
localSize += c;
long nowProcess = localSize / step;
if (nowProcess > process) {
process = nowProcess;
if (process % 10 == 0)
System.out.println("下载进度:" + process);
// TODO 更新文件下载进度,值存放在process变量中
}
}
in.close();
out.close();
boolean upNewStatus = ftpClient.completePendingCommand();
if (upNewStatus) {
result = DownloadStatus.Download_New_Success;
} else {
result = DownloadStatus.Download_New_Failed;
}
}
return result;
}

private void disconnect() throws IOException {
if (ftpClient.isConnected()) {
ftpClient.disconnect();
}
}

}

⑹ LINUX 如何锁定FTP登陆用户的目录

/etc/vsftpd/vsftpd.conf
中去掉下面这两句的“#”chroot_list_enable=YESchroot_list_file=/etc/vsftpd.chroot_list再在/etc
中建一个文件名为
:vsftpd.chroot_list
在文件中写上你想锁定的用户名,一行一个。目录权限一般是755

⑺ CentOs ftp 设置用户访问指定目录

  • 使用root账号登录centos系统

  • 检查是否已安装vsftp

    rpm -qa |grep vsftpd #未输出信息,表示未安装vsftp
  • 通过yum安装vsftp

    yum -y install vsftpd
  • ftp启动、重启、停止、状态查询命令

    service vsftpd start #启动ftpservice vsftpd stop #停止ftpservice vsftpd restart #重启ftpservice vsftpd status #查询ftp状态
  • 设置为开机启动(可设置)

    chkconfig vsftpd on
  • 设置配置文件

    vi /etc/vsftpd/vsftpd.conf

    修改如下内容:

    anonymous_enable=NO #设置不允许匿名账户登录chroot_local_user=YES #所有用户限制在主目录中chroot_list_enable=NO #不启动限制用户名单,直接限制所有用户userlist_enable=NO #当为YES时只有userlist_file文件中指定的用户才能登录allow_writeable_chroot=YES #(在文件尾部新增)防止用户有写入权限时报错local_root=/home/www #(在文件尾部新增)设置用户的根目录

    重启ftp

    service vsftpd restart
  • 创建ftp用户

    创建用户组

    groupadd ftpgroups

    创建用户

    # useradd 添加用户命令 -d /home/www 指定用户根目录 -g ftpgroups 加入用户组 ftptest用户名useradd -d /home/www -g ftpgroups ftptest

    设置用户密码

    passwd ftptest # passwd(命令) ftptest(用户名,根据你实际情况写)

    设置不允许用于系统登录

    usermod -s /sbin/nologin ftptest #ftptest(用户名,根据你实际情况写)
  • 设置文件权限

    chmod 755 /home/www

    设置目录拥有者

    chown -R ftptest:root /home/www #ftptest:ftp用户名 ; /home/www:文件目录

    设置防火墙
    查看防火墙状态,如果未启动,直接跳过本步骤

    systemctl status firewalld

    开放20、21端口(阿里云服务器还需配置安全组开放防火墙)

    firewall-cmd --permanent --zone=public --add-port=20/tcpfirewall-cmd --permanent --zone=public --add-port=20/udpfirewall-cmd --permanent --zone=public --add-port=21/tcpfirewall-cmd --permanent --zone=public --add-port=21/udpfirewall-cmd --reload #重新载入

    至此ftp服务安装成功,如果出现不能访问或不能写入的情况,就还需要设置SELinux(关闭)

    sestatus -v #查看SELinux状态,如果SELinux status参数为enabled即为开启状态setenforce 0 #临时关闭(不用重启机器)
热点内容
sql数据库数据路径 发布:2024-05-17 10:00:25 浏览:131
ftp服务器程序 发布:2024-05-17 10:00:21 浏览:676
php中的函数 发布:2024-05-17 09:53:34 浏览:940
优质网站为什么用ip服务器 发布:2024-05-17 09:43:34 浏览:792
安卓机图片存在哪里 发布:2024-05-17 09:42:54 浏览:61
ip地址怎么查看服务器上的文件 发布:2024-05-17 09:29:51 浏览:979
轱轮算法 发布:2024-05-17 09:29:10 浏览:95
安卓手机锁屏密码一般怎么画 发布:2024-05-17 09:29:05 浏览:347
堆栈是按组织的存储区域 发布:2024-05-17 09:29:02 浏览:695
sqllinkserver 发布:2024-05-17 09:19:35 浏览:458