2

I was doing this:
scp aaa.txt $user@$server:~/my-folder/aaa.txt
and it works.

I need something more "common" so i decided to create a specific user and to use a folder in the root path.
scp aaa.txt devuser@$server:/folder/aaa.txt
I receive this error:

Could not chdir to home directory /home/devuser: No such file or directory

I created devuser without the home directory (-M option of useradd) but I want the scp to save the file in the /folder directory that exists and has "devuser" as owner.
I don't understand the error.
SCP can save only on the home directory?
SCP always requires the home directory?

I'm executing SCP from PowerShell but I don't thinkl it's relevant.

[EDIT]

I created the /home/devuser folder with sudo mkdir /home/devuser, so not the user home and the owner is root, and the scp command works.

Alex 75
  • 133
  • 3
    why not just make that directory the users home dir? – hardillb Jul 30 '22 at 17:10
  • Please answer your own question, rather than making an edit. Self-answer is encouraged. Distinguishes questions from answers, and you can accept the solution you came up with. https://serverfault.com/help/self-answer – John Mahowald Jul 31 '22 at 15:26

1 Answers1

1

OpenSSH requires users to have a home directory, as child processes are chdir to their home as as a part of setting up a sane environment. Exceptions include when using ChrootDirectory

Create and set a home directory for this user. They do not need write access, if you wish to reduce clutter and enforce that files are stored somewhere not in home.

John Mahowald
  • 33,256
  • 2
  • 21
  • 39