大网数据广告活动
服务器运维问答

Unable to ssh into running dropbear sshd. "Bad password attempt" ...But password is correct

· 52CE 我爱测

For some reason, a running dropbear sshd i've got going in a Docker container is telling me Bad password attempt , even though i've doublechecked multiple times that both username and password is 100% correct. Dropbear is being s…

问题原文

原帖链接 · DhP · CC BY-SA 4.0

For some reason, a running dropbear sshd i've got going in a Docker container is telling me Bad password attempt , even though i've doublechecked multiple times that both username and password is 100% correct.

Dropbear is being started by supervisord with the following command:

/usr/local/sbin/dropbear -F -E -p 2222

by a user and group 'mysticbbs'. No errors are coming up when dropbear runs..

However, when i try to ssh into the container from the host computer, with:

ssh -o UserKnownHostsFile=/dev/null localhost -l mysticbbs -p 2222

('-o UserKnownHostsFile=/dev/null' , to prevent storing lots of different keys generated during testing/building of the dockerfile)

..ssh, like expected, gives me:

ECDSA key fingerprint is SHA256:0WadKddpa*[..blabla.]* Are you sure you want to continue connecting (yes/no)?

I'm then asked for the password. But whether or not i type it in, or paste it in, 100% correctly..I still get Permission denied, please try again. and dropbear logs the attempt with Bad password attempt for 'mysticbbs' from 172.17.0.1:35152 ..

  • I've tried setting a different/more complex password
  • Trying to ssh with dbclient from inside the container, with same user dropbear is running under, and running dropbear without using supervisord, makes no difference. (Bad password attempt for 'mysticbbs' from 127.0.0.1:48110) ..
  • The /etc/dropbear folder (and the keys) is chowned to 'mysticbbs:mysticbbs' and chmod to 700
  • The same problem occurs whether or not i use the dropbear from alpine's apk repo (v2018.76-r2), or build it from dropbear.nl source (both v2018.76 and v2017.75 tested)..
  • Deleting the keys and manually running dropbear with -R argument makes no difference.
  • Found a notation at https://github.com/mkj/dropbear , but i can't see how that could apply since user attempted to ssh in is the same as the one running dropbear:

>

If the server is run as non-root, you most likely won't be able to allocate a pty, and you cannot login as any user other than that running the daemon (obviously). Shadow passwords will also be unusable as non-root.

  • Shadow passwords just might the culprit..

Keys are generated during the docker build with the following:

   export RSA_KEYFILE=/etc/dropbear/dropbear_rsa_host_key
   export DSS_KEYFILE=/etc/dropbear/dropbear_dss_host_key
   export ECDSA_KEYFILE=/etc/dropbear/dropbear_ecdsa_host_key
   dropbearkey -t dss -f $DSS_KEYFILE
   dropbearkey -t rsa -f $RSA_KEYFILE
   dropbearkey -t ecdsa -f $ECDSA_KEYFILE
   chown -R mysticbbs:mysticbbs /etc/dropbear
   chmod -R 700 /etc/dropbear

password for mysticbbs user is set during docker build with:

   passwd mysticbbs -d '<password>' -u

What am i missing?..

已采纳解答

原帖链接 · DhP · CC BY-SA 4.0

As pointed to by @michael-hampton in comment, and the note at https://github.com/mkj/dropbear:

If the server is run as non-root, you most likely won't be able to allocate a pty, and you cannot login as any user other than that running the daemon (obviously). Shadow passwords will also be unusable as non-root.

My problems seems indeed to arise at shadow passwords when running dropbear as non-root user.

In my specific case, under alpine:3.9/BusyBox, it seems a more valid solution and workaround for me to add root to my 'mysticbbs' group, and drop root privileges as needed, rather than make /etc/shadow accessible to a user other than root (by e.g adding the 'mysticbbs', or a dedicated system user, to 'shadow' group(?)..I'm not even going to test that. Though i guess that could also be a potential workaround.).

EDIT: Adding the user that dropbear is being run under to shadow group just seems easier..And after all /etc/shadow is still chmod 640 (writable to root user only, though readable to shadow group)

ls -la /etc/shadow 

-rw-r----- 1 root shadow 503 Feb 6 16:33 /etc/shadow

(Note: Probably not recommended in where high security is top priority though)

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-02-06)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。