I'm trying to copy files from one server to another with scp.

On both servers, I configured ssh port to 222. sshd_config for both servers is exactly the same (no RootLogin, PasswordAuthentication enabled)

For many reasons too long to explain here, I can't use key authentication.

When I use scp to copy from server A to server B (logged to A), it works. But it doesn't work when I'm doing the same thing from B to A (logged to B) : I get an error message "permission denied" and scp doesn't ask me for password (although the password authentication is enabled)

Here is the command I use (logged on server B) :

scp -P 222 -vvv ~/backup/file user@serverA:/home/user/backup

And here are the last lines of the output :

debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: password
debug3: start over, passed a different list password
debug3: preferred publickey,keyboard-interactive
debug1: No more authentication methods to try.
user@serverA: Permission denied (password).

Why doesn't scp ask me for password, whereas "password" is enabled (as it is written in the 2nd "debug1" line) ?

Thank you.

  • You sure that PW auth for user is enabled? If I try this with PW and -vvv I get this output: debug3: send packet: type 50 debug2: we sent a password packet, wait for reply debug3: receive packet: type 51 – Lenniey Sep 21 '18 at 7:46

The best solution would be to ask the person who disabled publickey authentication on that server why and then go fix that. Using publickey authentication is more convenient and more secure than passwords.

The reason authentication fails for you is that no authentication method is enabled on both client and server. The authentication methods enabled on the server are:

debug1: Authentications that can continue: password

And the authentication methods enabled on the client are:

debug3: preferred publickey,keyboard-interactive

You can pass -o PreferredAuthentications=password to scp to only use password authentication.

  • 3
    You're my man! "UsePasswordAuthentication" was set to "No" in ssh_config on server B. Corrected it to "yes", and it's ok. Thanks a lot. – Harkonnen Sep 21 '18 at 8:43

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.