Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3754098
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:29:35+00:00 2026-05-19T09:29:35+00:00

I am wishing to automate adding SFTP users. My commands required are the following,

  • 0

I am wishing to automate adding SFTP users. My commands required are the following, taking for example adding the user ‘jason’:

useradd jason
passwd jason
mkdir /home/jason
chown root:jason /home/jason
chmod 775 /home/jason
usermod -d /home/jason jason
usermod -a -G sftp jason
mount --bind /srv/ftp/~jason /home/jason

How may I replace each name with a variable for BASH, and have it ask for password at the beginning so it may plug it in where it is required?

I will try to learn to do this on my own, my mental capacity is very limited right now..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:29:36+00:00Added an answer on May 19, 2026 at 9:29 am
    #!/bin/bash
    
    read -p "Enter user: " user
    read -s -p "Enter password: " pass
    
    useradd "$user"
    passwd --stdin "$user" <<<"$pass"
    mkdir /home/"$user"
    chown root:"$user" /home/"$user"
    chmod 775 /home/"$user"
    usermod -d /home/"$user" "$user"
    usermod -a -G sftp "$user"
    mount --bind /srv/ftp/~"$user" /home/"$user"
    

    Note that if your version of passwd doesn’t support the --stdin option, you’re going to need to use something like expect or autoexpect

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wishing I could do something like the following in SQl Server 2005 (which
I am a Javascript Junkie and wishing to test around some codes. new RegExp(user=
I got the following code, wishing to wrap a group of strings nicely in
my application is where user sends a well-wishing message. It has Spinner which contains
I'm wishing for a simple index more or less with my PHP note taking
I'm wishing to figure out how many milliseconds a particular function uses. So I
I find myself wishing an interface could be composed of methods that are fulfilled
In doing a bit more programming with Firebase today, I found myself wishing for
Im currently wishing to transfer data from a remote server by capturing printed data
After some advice. I have a client wishing to have an app which lets

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.