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

Multiple keys are added to authorized_keys without line breaks #283

Open
asostechnix opened this issue Sep 16, 2021 · 5 comments
Open

Multiple keys are added to authorized_keys without line breaks #283

asostechnix opened this issue Sep 16, 2021 · 5 comments

Comments

@asostechnix
Copy link

I am running atmoz/sftp:alpine in Azure Container Instances.

I have two RSA public keys for the same user, which are mounted as a secret volume into /home/username/.ssh/keys

The file /home/username/.ssh/authorized_keys does contain both keys once the container is running but without a line break between them, which causes key auth to fail.

I have tried adding a single line break to the end of the secrets in the volume definition but it didn't make a difference.

@TobiTh
Copy link

TobiTh commented Sep 30, 2021

We have the same issue. A manual insertion of a line break in the /home/username/.ssh/authorized_keys file between the keys has solved the login issue.

@jalleyne
Copy link

Same issue here, building a Helm chart using this base image and running into the issue. Helm strips out any whitespaces so its even more difficult to add them in. Confirming this is an issue so I will look at the code to submit a PR if I can make the time today.

@jalleyne
Copy link

jalleyne commented Nov 11, 2021

I have a working fix that forces a new line with this proposed change. Does anyone see any concerns with this update?

Suggested fix:

echo -e "$(cat "$publickey")" >> "$userKeysAllowedFileTmp"

Existing read and append code:

for publickey in "$userKeysQueuedDir"/*; do
cat "$publickey" >> "$userKeysAllowedFileTmp"
done

@aiac
Copy link

aiac commented Mar 30, 2022

@jalleyne i needed to build the image from repo because there is no ARM image in Docker hub. I can confirm that your change fixed the key files error that was causing container to fail on init. Thank you. It works with the latest alpine

@tmakin
Copy link

tmakin commented Apr 12, 2022

For anyone else hitting this when deploying via config map here is a hack that allows multiple public keys to be supplied.

apiVersion: v1
kind: ConfigMap
metadata:
  name: sftp-public-keys
data:
  # both keys listed in single file
  keys.txt: |
    ssh-rsa AAAAB3Nz...3u8D
    ssh-rsa AAAAB3Nz...JQ0pz

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

5 participants