Coder Social home page Coder Social logo

ansible-sftp's Introduction

SFTP-Server

An Ansible role which configures an OpenSSH server for chrooted SFTP access. The role is built in such a way that it will not unnecessarily alter a user's OpenSSH customisations. Instead, it simply changes the crucial bits that it needs to, and adds the rest of its configuration in the form of a custom config block (OpenSSH's lack of some form of conf.d/ support forces this behaviour).

Requirements

It is advisable that scp_if_ssh be set to true in the ssh_connection section of your ansible.cfg file, seeing as how Ansible uses SFTP for file transfers by default, and you can easily lock yourself out of your server's SFTP by using this role. The SCP fallback will continue to work. Example config:

; ansible.cfg
...
[ssh_connection]
scp_if_ssh=True

Other than that, only Ansible itself is required. Tested using Ansible 1.5 and 1.6.

Role Variables

The following role variables are relevant:

  • sftp_home_partition: The partition where SFTP users' home directories will be located. Defaults to "/home".
  • sftp_group_name: The name of the Unix group to which all SFTP users must belong. Defaults to "sftpusers".
  • sftp_directories: A list of directories that need to be created automatically for each SFTP user. Defaults to a blank list (i.e. "[]").
  • sftp_users: A list of users, in map form, containing the following elements:
    • name: The Unix name of the user that requires SFTP access.
    • password: A password hash for the user to login with (leave blank if a key is used exclusively).
    • authorized: A list of files placed in files/ which contain valid public keys for the SFTP user.

Example Playbook

---
- name: test-playbook | Test sftp-server role
  hosts: all
  sudo: yes
  vars:
    - sftp_users:
      - name: peter
        password: "$1$salty$li5TXAa2G6oxHTDkqx3Dz/" # passpass
        authorized: []
      - name: sally
        password: ""
        authorized: [sally.pub]
    - sftp_directories:
      - imports
      - exports
      - other
  roles:
    - sftp-server

License

Licensed under the MIT License. See the LICENSE file for details.

ansible-sftp's People

Contributors

asavoy avatar johanmeiring avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.