SCP Permission denied

~OSD~ 2,126 Reputation points
2022-08-05T13:54:20.307+00:00

Hi,

I am using Windows 10 as source computer and nd Windows 11 as destination computer.
I am getting permissions denied error even I am sure that password I am using is correct.

scp -r director-on-local-machine username@machine-ip:path-to-directory

Permission denied, please try again:

Afterwards, modified the ssh file with changes as shown in the below figure:

228579-ss-config.png

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,701 questions
Windows 10 Setup
Windows 10 Setup
Windows 10: A Microsoft operating system that runs on personal computers and tablets.Setup: The procedures involved in preparing a software program or application to operate within a computer or mobile device.
1,909 questions
Windows 10 Security
Windows 10 Security
Windows 10: A Microsoft operating system that runs on personal computers and tablets.Security: The precautions taken to guard against crime, attack, sabotage, espionage, or another threat.
2,767 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,281 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,389 questions
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. MotoX80 32,076 Reputation points
    2022-08-07T11:36:52.107+00:00

    In your sshd_config did you identify the users who are allowed to connect?

    # Authentication:  
    Allowusers testuser  
    
    1 person found this answer helpful.

  2. MotoX80 32,076 Reputation points
    2022-08-09T13:45:32.34+00:00

    i just ran some tests and that Pubkey statement is not the problem. I was not able to login with my admin account, so I had to comment out the AllowUsers because it was only letting my testuser in.

    Add these 2 lines to your config.

    SyslogFacility LOCAL0
    LogLevel Debug1

    Then recycle the sshd service and try to log in again. Check for errors in the C:\ProgramData\ssh\logs\sshd.log file.

    Here is my sshd_config file. (Update; I used Filezilla and connected via SFTP.)

    # This is the sshd server system-wide configuration file.  See  
    # sshd_config(5) for more information.  
      
    # The strategy used for options in the default sshd_config shipped with  
    # OpenSSH is to specify options with their default value where  
    # possible, but leave them commented.  Uncommented options override the  
    # default value.  
      
    #Port 22  
    #AddressFamily any  
    #ListenAddress 0.0.0.0  
    #ListenAddress ::  
      
    #HostKey __PROGRAMDATA__/ssh/ssh_host_rsa_key  
    #HostKey __PROGRAMDATA__/ssh/ssh_host_dsa_key  
    #HostKey __PROGRAMDATA__/ssh/ssh_host_ecdsa_key  
    #HostKey __PROGRAMDATA__/ssh/ssh_host_ed25519_key  
      
    # Ciphers and keying  
    #RekeyLimit default none  
      
    # Logging  
    #SyslogFacility AUTH  
    # Local0 is the log folder  
    SyslogFacility LOCAL0  
    LogLevel Debug1  
      
    # Authentication:  
    #Allowusers testuser  
      
    #LoginGraceTime 2m  
    #PermitRootLogin prohibit-password  
    PermitRootLogin yes  
    #StrictModes yes  
    #MaxAuthTries 6  
    #MaxSessions 10  
      
    PubkeyAuthentication yes  
    # The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2  
    # but this is overridden so installations will only check .ssh/authorized_keys  
    AuthorizedKeysFile .ssh/authorized_keys  
      
    #AuthorizedPrincipalsFile none  
      
    # For this to work you will also need host keys in %programData%/ssh/ssh_known_hosts  
    #HostbasedAuthentication no  
    # Change to yes if you don't trust ~/.ssh/known_hosts for  
    # HostbasedAuthentication  
    #IgnoreUserKnownHosts no  
    # Don't read the user's ~/.rhosts and ~/.shosts files  
    #IgnoreRhosts yes  
      
    # To disable tunneled clear text passwords, change to no here!  
    PasswordAuthentication yes  
    #PermitEmptyPasswords no  
      
    # GSSAPI options  
    #GSSAPIAuthentication no  
      
    #AllowAgentForwarding yes  
    #AllowTcpForwarding yes  
    #GatewayPorts no  
    #PermitTTY yes  
    #PrintMotd yes  
    #PrintLastLog yes  
    #TCPKeepAlive yes  
    #UseLogin no  
    #PermitUserEnvironment no  
    #ClientAliveInterval 0  
    #ClientAliveCountMax 3  
    #UseDNS no  
    #PidFile /var/run/sshd.pid  
    #MaxStartups 10:30:100  
    #PermitTunnel no  
    #ChrootDirectory none  
    #VersionAddendum none  
      
    # no default banner path  
    #Banner none  
      
    # override default of no subsystems  
    Subsystem sftp sftp-server.exe  
      
    # Example of overriding settings on a per-user basis  
    #Match User anoncvs  
    # AllowTcpForwarding no  
    # PermitTTY no  
    # ForceCommand cvs server  
      
    Match Group administrators  
           AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys  
    Match user testuser  
           ChrootDirectory c:/temp  
    
    1 person found this answer helpful.

  3. MotoX80 32,076 Reputation points
    2022-08-05T17:47:11.287+00:00

    even I am sure that password I am using is correct

    Check the Security eventlog for logon errors.

    Check the OpenSSH server logs for errors.

    https://github.com/PowerShell/Win32-OpenSSH/wiki/Logging-Facilities


  4. Rich Matheisen 45,096 Reputation points
    2022-08-06T18:28:26.757+00:00

    Before trying to use scp, try logging on to the remote machine using ssh. If ssh doesn't work there's is no hope of scp succeeding.

    Are the machines in a workgroup or a domain?


  5. ~OSD~ 2,126 Reputation points
    2022-08-08T14:59:36.76+00:00

    Have some issues to upload screenshots, that's why using this section to upload.229227-t2.png

    229198-temp3.png

    229229-t1.png