Code Monkey home page Code Monkey logo

ansible-sftp's People

Contributors

ameng avatar andyshinn avatar bee-keeper avatar cnotin avatar ernestoforeseemed avatar flatrocks avatar giner avatar johanmeiring avatar joostrijneveld avatar markstos avatar mrexojo avatar mrtango avatar s-fu avatar smag-bmesseca avatar thomasbilk avatar tomasbedrich avatar tomasfse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-sftp's Issues

Permissions on /home being modified

Since this PR, we have been having an issue where this role is now modifying the entire /home directory instead of just the SFTP user's home directory.

e735362#diff-2cb1ad4f3eb0ea704c74a73689ad1654

- name: install-sftp
  include_role: 
    name: johanmeiring.sftp-server
  vars:
    - sftp_allow_passwords: true
    - sftp_enable_logging: true
    - sftp_users:
      - name: Default
        password: # passpass
        shell: False
        home: /home/Default
        sftp_directories: 
          - { name: uploads, mode: 700 }

results in:
drwxr-x---. 7 root sftpusers 95 Sep 17 16:38 home

Chrooted user "nologin" shell

When setting chrooted sftp_users with shell: false, the users are created with the /sbin/nologin shell to prevent any access but SFTP. (see main.yml, line 54)

    shell: "{{ None if (item.shell | default(True)) else '/sbin/nologin' }}"

However on my Ubuntu 16.04 system, the correct "no login" shell is actually /usr/sbin/nologin. Since /sbin/nologin did not exist, the user session could not start up, and I got a misleading message saying authentication failed.

Manually changing this value to /usr/sbin/nologin solved this access problem.

Does not function with CentOS 8 when enabling SELinux

This role tries to install the libsemanage-python on CentOS 8. But there is no such package for that release. Instead you should use python3-libsemanage.

However, i dont really think its this role's responsibility to ensure the necessary package is installed. I'm fine with managing that myself, which would add greater flexibility on which distributions this is deployed. From what i can tell. It seems that the package task is the only one limiting which OS's this can be deployed against anyway.

Mode default value causing Error while working with directories

Hi,

I've been getting this error:
fatal: [local]: FAILED! => {"msg": "template error while templating string: expected token ',', got 'integer'. String: {{ item.mode | default(0750) }}"}

out of no where when creating new SFTP instances.
I think it's related to the default file mode
as I was able to make the error go away after re-running with quotes around the number. (default('0750'))

Versions:

ansible 2.10.9
  config file = None
  configured module search path = ['/home/matt_kizaric/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]

I'm running debian-10 on GCP if that makes any difference. Would you like me to open a PR to fix the template?

Change regular expression in SFTP-Server | Alter sftp subsystem entry

The regular expression used to find the existing Subsystem sftp entry is dangerous. You should probably change it to

regexp="^Subsystem(\s+)sftp

That way, it will find the line regardless of how much whitespace is in the line. Otherwise, if the current line had, say, a tab between Subsystem and sftp, it would insert a new line, and the ssh service would fail to restart because of multiple sftp Subsystems defined in the config file, potentially locking you completely out of the server.

Feature request: add multiple groups to users

Hi,

What do you think about adding multiple additional groups to the users instead of a single one with sftp_group_name ? in my case, the users being added with this role must have write access to different existing directories owned by different groups. Making this role add multiple groups would be better than modifying the added users after the role is run to add the extra groups, like this:

  tasks:
    - name: Modify users and add them to additional groups
      user: name={{ item }}
            groups=www-data,systemd-journal,systemd-network
            append=yes
      with_items:
        - sftp_users

A task similar to that one could be used, and maybe renaming sftp_group_name to sftp_group_names, WDYT ?

Can you suggest a SSH hardening role that is compatible with ansible-sftp?

Since you are maintaining this role, I wonder if you are using a specific SSH hardening role that would be compatible with it?

For most of my machines, I use https://github.com/dev-sec/ansible-ssh-hardening, which completely rewrites the sshd config, and most roles I've found do the same.

As such, using ansible-sftp with it will mean that the first role will erase the SFTP setup that your role provide, then your role will set it up again, generating changes during the run.

Do you have any suggestion of hardening role for which this wouldn't happen?

Thanks! (happy to create a little documentation PR later if there is something worth sharing).

User Directories skipping

Hi

I'm running a playbook based on the example playbook but it is not creating the sub directoreis for the user home directory (incoming, etc...)

TASK: [SFTP-Server | Create directories] ************************************** skipping: [XXXXXXX.eu-west-1.compute.amazonaws.com]

example playbook shown below; Am I missing something?

thanks
paul

vars:
    - sftp_users:
      - name: test_user
        password: "$1$salt$XXXXXX"
        authorized: []
        sftp_allow_passwords: true
    - sftp_directories:
      - imports
      - exports 

`sftp_directories` is creating directories at "/home/user/ "

As i see, when I specify :
sftp_start_directory: "/datadrive"
sftp_directories : "/datadrive/error"

It is creating directories at "/home/user/datadrive/error"
what i want is creating directories at "/datadrive/error"

What should I do to deal with it?

Allow custom arguments to server command

I would like newly-created directories to be group-writable (0770 permissions). Passing the -u argument to the internal-sftp command can accomplish this, but this module has no mechanism to configure this and other arguments to the daemon. I would be happy to submit a PR for this.

Allow usage for external servers

Hi !
We used to use this role exclusively on localhost and, while I was trying to migrate to execute it on multiple servers (one 'server' and multiple 'clients') I found out I couldn't due to the use of a lookup, which only executes on the host executing the ansible script, and therefore cannot find the files who have been created on the clients.

I've created a workaround using slurp, but I was wondering if it was me who misunderstood how to use this module ? I'll create a PR if this is not the case.

Thanks,

chroot not working

Hi,

I'm testing your role but it seems that the user chroot is not working. I copy pasted the example in the README file, and after logging in with the user sally I can see the contents of the root directory:

$ sftp -i ~/.ssh/id_rsa [email protected]
Connected to xxx.xxx.xxx.xxx
sftp> pwd
Remote working directory: /var/tmp/sally
sftp> cd /
sftp> ls
bin              boot             dev              etc              home             initrd.img       initrd.img.old   lib              lib64            lost+found       media            
mnt              opt              proc             root             run              sbin             snap             srv              sys              tmp              usr              
var              vmlinuz          vmlinuz.old

Does it work for you ?

Password hash

Hello,

Regarding the password hash the Readme states "A password hash for the user to login with" and the example given is:

password: "$1$salty$li5TXAa2G6oxHTDkqx3Dz/" # passpass

What are the commands to create compatible hashes from user chosen passwords so that they can be documented and added to the Readme?

Thanks,

Check mode fails on "Correct ownership and permission of home directories"

Thanks for this role again! I'm writing down this issue on a new deployment, maybe I'll come back to fix it later here.

If you run with --diff --check before the deploy has been done, you will get an error similar to:

TASK [johanmeiring.sftp-server : SFTP-Server | Correct ownership and permission of home directories] **************
# SNIP
"msg": file (/home/user) is absent, cannot continue

Jailing user inside directory

HI. Will be this feature added for example to /var/www/example.com/uploads?
or what should I do to add it in own task?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.