Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does atmoz / sftp support 2 factor authentication with ssh public key and password? #385

Open
ctlgao opened this issue Aug 5, 2023 · 1 comment

Comments

@ctlgao
Copy link

ctlgao commented Aug 5, 2023

Does anyone know if atmoz / sftp support 2 factor authentication with ssh public key and password? if yes, how to associate a ssh public key with an user account? thanks

@adrian-amaglio
Copy link

adrian-amaglio commented Oct 9, 2023

Hello,
I am not a maintainer of this repo but I made your request work on my computer by adding this config line AuthenticationMethods "publickey,password"
to the /etc/ssh/sshd_config file and restart the container.

There is currently no option to add it on the fly.

You can create a custom script in /etc/sftp.d that add the line for you in the config.
This script for instance is working if mounted on the container in /etc/sftp.d/forceauth.sh

#!/bin/bash    
    
if [ ! -v AuthenticationMethods ] ; then    
    AuthenticationMethods="publickey,password"    
fi    
    
if [ -z "$(grep AuthenticationMethods /etc/ssh/sshd_config)" ] ; then    
    echo lol    
    echo "AuthenticationMethods \"$AuthenticationMethods\"" >> /etc/ssh/sshd_config    
else    
    echo mdr    
    sed -i "s/AuthenticationMethods .*/AuthenticationMethods \"$AuthenticationMethods\"/" /etc/ssh/sshd_config
fi    

With this script in the container, you can even change the AuthenticationMethod with the AuthenticationMethod env var.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants