Scp linux permission denied publickey

«Permission denied, try again» while transferring files with scp

I have two servers (A and B) and my local machine. I’m trying to transfer a file from server A to server B. From server A:

scp ./backup.tar user@server.b:/home/public/ Permission denied, please try again. Permission denied, please try again. Permission denied (publickey, password). lost connection 
scp user@server.a:/home/public/backup.tar . Permission denied, please try again. Permission denied, please try again. Permission denied (publickey, password). lost connection 

Same error message when I try from my local computer. What’s going on? This is what I get when I try to ssh from Server A to Server B with the debug flag:

debug1: Authentications that can continue: publickey,password debug1: Next authentication method: publickey debug1: Trying private key: /home/private/.ssh/identity debug1: Trying private key: /home/private/.ssh/id_rsa debug1: Trying private key: /home/private/.ssh/id_dsa debug1: Next authentication method: password debug1: read_passphrase: can't open /dev/tty: No such file or directory debug1: Authentications that can continue: publickey,password Permission denied, please try again. debug1: read_passphrase: can't open /dev/tty: No such file or directory debug1: Authentications that can continue: publickey,password Permission denied, please try again. debug1: read_passphrase: can't open /dev/tty: No such file or directory debug1: Authentications that can continue: publickey,password debug1: No more authentication methods to try. Permission denied (publickey,password). 

Does this mean it can’t find my terminal? I should mention that server B is a subdomain of server A. My hosting provider however sees them as completely different entities and they are not hosted on the same LPAR. Conclusion I’ve emailed my hosting provider and it seems that there is a small bug related to the version of ssh and the OS (freeBSD). Currently, my workaround is to (1) scp the file locally to my machine, then (2) scp the file locally to the second server. This is what scp -3 is supposed to do, but that fails as well.

Источник

scp copy over ssh doesn’t work — permission denied error, please?

It’s driving me nuts! I just want to transfer one simple file from laptop to server. I’m using ubuntu on both machines. So I have:

-rwxr-xr-x 1 sandro 414622 2011-10-14 23:42 sandrophoto-html.tar.gz 
sudo scp -P XXXX sandrophoto-html.tar.gz usern@server.local:/media/xx/xx/xx 

And I get: scp: /media/xx/xx/xx/sandrophoto-html.tar.gz: Permission denied p.s. I might be doing this other way around — I want to send file tar.gz that is located on my desktop, to remote server into the folder /media/yadayda

In my case, It was security reason on the receiving side, I had to chmod the directory to allow the remote user to write the file (i chmod 777 the directory — but it is internal lab)

In my case, it was an ownership issue from the source side. Go to the source directory and change the ownership | sudo chown [username] [directoryname] |

7 Answers 7

You have things in the right order from what I understand, the general way an scp is done is:

scp sourceuser@sourcehost:/path/to/source/file destinationuser@destinationhost:/path/to/destination/ 

Judging by your question, you have a local file you want to send to the destination server. So you have the right syntax which is good!

Читайте также:  Посмотреть wifi адаптеры linux

If you’re getting permission denied, then you’re not using the correct username or something’s amiss with the authentication. Most likely, it’s because the sudo command only works locally, for starters, so it won’t give you root on the remote box, so that’s probably the problem. Make sure that the user you are logging in as on the remote server has write permissions to the location you’re trying to write to.

If the problem is the destinationuser doesn’t have access to that location without sudo, move the file to the destinationuser’s home folder then sudo mv the file from the shell on the other server to put it in the right location.

Источник

(Scp — Permission Denied (Public Key) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

I am trying to use the linux command Scp to get a file of a server xx.xx.xxx.xx and onto my Desktop. Here is my syntax

scp admin@xx.xx.xxx.xx:/scraper/summary.csv /home/barns/Desktop 
'permission denied (publickey)' 

2 Answers 2

Yes, it’s correct. Run the command with -vvv option to find out at what stage does it break exactly. It may be either a local issue (like private key being world-readable), remote (like your public key not being found), or something during the exchange (like no common ciphers). The debug output should give you information you need.

 scp admin@xx.xx.xxx.xx:~/scraper/summary.csv /home/barns/Desktop 

I needed a ~ symbol before the directory name

Linked

Hot Network Questions

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

Eliminate SCP Permission Denied Error in 5 Ways

SCP Permission Denied

The SCP permission denied is an error message that is displayed when the user tries to copy files or data from a remote host that he does not have permission to access or tries to store the data in the root directory of his system, which does not allow the user to store data in it. In either of the cases, permission to access the data is required.

The SCP (Secure Copy Protocol) is a data transfer protocol explicitly used to copy data from one host to another over the network. The protocol runs on top of SSH (secured shell), which uses asymmetric cryptography to protect the data during transfers. Today we show you how to deal with protocol’s scp permission denied error.

Defining SCP

SCP utility running on windows.

SCP is shot for secure copy protocol. It is an application layer protocol that works on top of the SSH protocol, a security protocol implemented between the application layer and the transport layer (TCP in this case). Scp command is compatible with all mainstream operating systems like Windows, Linux , macOS, etc. There are other similar protocols to the scp, such as SFTP (secure file transfer protocol), which transfers the data and performs data management functions. SCP comes pre-installed on macOS, Linux, and Windows. The user must have appropriate rights and permissions to avoid an scp permission denied error.

Читайте также:  Kali linux hacking passwords

How to copy files using SCP

The scp command is not very complicated and simple to use. To perform any actions using the SCP without facing any permission error, you must have at least read permission on the remote host and otherwise write permission on the localhost. You might receive an scp permission error. The syntax of the command is intuitive and straightforward to use. Follow the given syntax to copy a file to the target location using scp.

scp [OPTION] [email protected]_host:file1 [email protected]_host:file2

The OPTIONs are additional options that can be used to perform tasks according to the provided arguments. [email protected]_host:file1 is the file’s name to be copied prefixed with the username and address of the source host. And [email protected]_host:file2 is the name to the resultant file with the specified address prefixed with the target host username and machine address. Use the -r option to copy all the files and subdirectories inside the folder recursively.

SCP permission denied

The scp permission denied error shows up when the users do not have the required rights or permission to perform a specific operation. Executable permissions are not required on any host while using the scp command. It requires read permissions on the source system and writing permission on the target system. There might be some ownership issue with the file or directory if you are receiving the scp permission denied error.

SCP permission denied ownership issue.

If the remote host’s directory from which the user is trying to copy the file or data is not owned by the username specified in the command, then an SCP permission denied error could be encountered. Follow the given steps to resolve this issue.

  • Login into the remost host with admin privileges.
  • Change the ownership of the directory to the USER instead of the root.
  • Use the chown (change owner) command to change the ownership.
  • Now run the scp command again.

Try using –verbose option

The -v or –verbose options are used to provide a detailed output of the program’s working. Use this option with the scp command to wisely observe the problems occurring under the hood and then troubleshoot the scp permission denied problem accordingly.

-v option along with the scp command.

Use -P to specify the port number

Sometimes hidden or silent processes run on the arbitrary standard ports number on either host. For example, on the remote host, the chosen port number might be used by another process for another connection. Conflicting port numbers can also cause errors. Use the -P option to provide a specific arbitrary port number in such a case. NOTE – keep in mind that an uppercase -P is used to specify the port number while a lowercase -p is used for other purposes related to the original file.

Specifying the port number while using scp

SCP permission denied (publickey)

The SCP permission denied (public key) is an error message that the users are reported to face when they try to login to their AWS EC2 instance while using the passphrase-less authentication protocol such as ssh. The ssh passwordless authentication makes use of asymmetric cryptography to authenticate the user. If you provide the wrong private key to the scp utility, the scp permission denied error occurs. By default, the scp uses the default ssh private key directory to authenticate the user. Use the -i option to provide your specific private key file.

Читайте также:  Alt linux для планшета

Scp permission denied resolved

Gcloud scp permission denied

Google provides cloud computing services in many forms. Google Compute Engine is one such way to use googles cloud services. The glcoud is a command-line utility tool that can interact with the cloud server. The cloud compute scp command is used to copy files from a google cloud virtual machine to your local computer. The syntax is almost similar to the SCP command. Complete documentation of the command can be found here.

If you receive an SCP permission error while copying data from your cloud host, then try downloading the content as the root user. Add @root before your destination or target address to resolve this issue.

Источник

I get a permission denied (public key) when I try to scp in ssh

I can login to the remote server via ssh and navigate through it’s file system, but as soon as I try to scp a file from the server to my laptop I get an error message. Example:

user@server:/file$ scp -r user@server: /file/ /My/Home/Dir [I Hit Enter] Permission denied (publickey) 

The command you are running above seems to be while on the server, copying a file via scp from the server itself to the server. You need to run scp from your laptop, not from the server.

@Paul excellent point. DanielToebe, System Preferences -> Sharing -> Remote Login should be enabled for you to be able to scp to a OS X laptop

3 Answers 3

Your server doesn’t have a private key to access to your laptop. The relationship is only one-way.

You’ll need to create a key on your server and add its public key to your laptop. Here’s a basic outline:

  1. SSH in to your server
  2. run ssh-keygen to generate a key
  3. copy the generated public key to your laptop.
  4. You should now be able to SSH back in to your laptop.

Rather than using SCP to push a file from the server, to your laptop. Why not try using SCP on your laptop to pull a file from the server? This would mean you wouldn’t need to setup an an SSH server on your laptop, or configure public key authentication for your server. The SCP command you initially posted intends to do this. You simply ran it from the wrong place.

Rather than executing this command from within your SSH session on the server, run it from a terminal window on your laptop.

I had the same trouble. My fault was, that I forgot to add my private key to the ssh-agent after I reformatted my partition. If you have the same issue, fix it by:

$ ssh-add /path_to_your_private_key 

You must log in to answer this question.

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

Оцените статью
Adblock
detector