1

When connecting to sftp by sftp user@serveripaddress, I checked file list by ls, but this shows nothing in remote directory, also tried cd but no other paths I can move to.

I tried lls, this shows directory for my project.

tried to add directory in remote by, mkdir test but gives me error:

Couldn't create directory: Permission denied

I have file found in local directory in /backups/mall/20180524_mallproducts.csv

So now I'm trying to test upload file to remote directory by command, put backups/client/mall/20180522150444_mallproduct.csv /

this give me result of:

Uploading backups/client/mall/20180522150444_mallproduct.csv to /20180522150444_mallproduct.csv

remote open("/20180522150444_mallproduct.csv"): Permission denied

so I use chmod, but this gives me error, because remote directory is empty(no files or folders):

Couldn't setstat on "/": Permission denied

What could possibly be wrong? how can I change permission in sftp?

In docker-compose.yml, this is my setting for sftp,

sftp:
    image: atmoz/sftp
    restart: always
    volumes:
        - ./data/sftp:/home/foo/upload
    ports:
        - "2222:22"
    command: sftp:pass:48

I was expecting folder home when accessing SFTP, but directory is empty.

At first I was accessing sudo docker-compose exec sftp bash, It has /home/foo/upload directory to it.

But then I access by sftp user@serveripaddress, that is where I found out my code is trying to upload here.

This is the code for uploading via sftp:

<?php

namespace Mall\Infra\Transfer;

use phpseclib\Net\SFTP;

class SftpPutTransfer
{

    /**
     * @var File $name
     */
    public function put(string $remote, string $local)
    {
        $sftp = new SFTP('user', 22);
        if (!$sftp->login('user', 'pass')) {
            var_dump('failed');
        } else {
            var_dump('success');
            var_dump($sftp->rawlist());
            $sftp->put($remote, $local, SFTP::SOURCE_LOCAL_FILE);
        }
    }
}

I'm confused on what SFTP to connect and test.

1

According https://github.com/atmoz/sftp documentation, you must create at least one subdirectory and use it from there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.