Error message using scp but not sftp (bash shell)

After I changed the login shell to bash every time I use scp I get this following error message:
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Not a tty

I'm able to transfer files successfully but this message is kind of annoying and also I want to know what's causing this error.
I'm running openssh with dropbear disabled on 17.01.4.

I found a similar post here and it looks like this is a really old issue but still I wasn't able to find a good solution.

Facing same issue. @jow, @hnyman -- any insight on how to fix that?

That is generally a sign that OpenSSH is unable to both authenticate the user and to create a shell for them. sftp is a subsystem so it behaves slightly differently. Make sure your /etc/shadow has a valid password-change date and expiration date, along with a valid shell that is present in /etc/shells for the mode in which you are running. Make sure that the specified user's home directory exists in the mode you are running, at the time you make the request as well.

Just plain ssh -vv you@your.router may provide some insight. Be aware that OpenSSH authenticates first, then deals with "problems" it finds, such as those in /etc/shadow.

(I've got a patch for getting OpenSSH to run under "failsafe" mode that I hope to find the time to submit this weekend.)

1 Like

Plain ssh of course works and nothing seems out of order with -vv option either.
The /etc/passwd has the correct shell for the user (which is also present in /etc/shells).

Given that ssh works (and scp also does to an extent that it transfers files despite spitting out an error message) -- I question if it would make sense to mess with dates in /etc/shadow?

I was having all kinds of problems until I set the "password set days" to April 1, 2018 (the day I did it, but an amusing date, so I kept it). The "0" was accepted by dropbear but disliked by OpenSSH. (This is for failsafe, so there is no root password.)

diff --git a/package/base-files/files/etc/shadow b/package/base-files/files/etc/shadow
index 4b4154f..870d87c 100644
--- a/package/base-files/files/etc/shadow
+++ b/package/base-files/files/etc/shadow
@@ -1,4 +1,4 @@

Edit: If you've already set your password using passwd, I would expect that at least on your overlay's version of /etc/shadow that field should already be populated.

@jeff -- tried adding 17622 into /etc/shadow and restarting dropbear, but I'm still getting the "shell-init: error retrieving current directory: getcwd: cannot access parent directories: Not a tty" error message when trying to scp files to the router.

Might be that dropbear doesn't like bash? -- I typically keep the root account completely clean with the default shell for the OS, and create another user that I use for "everything". It could be that if everything isn't mounted and properly configured that bash isn't finding libraries that it needs to run.

No idea. I have never tried using bash as a shell in the router.