Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to configure an ubuntu vps. I have set up ssh secure login using rsa public and private keys from a local machine.

As well as disabling root login I have also set up iptables and configured to allow ports 80 and 22 (port 22 only from my ip address) for the ssh tunnel.

I can connect fine using ssh but when I try using scp from my local machine

sudo scp /var/www/filetocopy user@remoteaddress:/var/www/filetocopy

I get this error

Permission denied (publickey).

Does this mean that I have to generate another public key/private key pair or is there a way of using the key that the ssh uses?

many thanks in advance

share|improve this question
    
When you say you can connect fine using ssh, do you mean using sudo ssh? –  DerfK Aug 22 '11 at 15:57
    
yes I mean sudo ssh –  user866190 Aug 22 '11 at 16:17
    
Don't you need to ssh first , and after the tunnel is established, then run the SCP commands? –  djangofan Aug 22 '11 at 16:44
    
@djangofan - No –  Aaron Copley Aug 22 '11 at 16:53

1 Answer 1

up vote 2 down vote accepted

SCP works over SSH so there shouldn't be any additional setup or configuration. Throw a -v in there after scp and let's get some more information.

That said, it looks like the SCP command isn't passing the key you generated. Try specifying the key file with the -i option. If it is in a non-standard location or non-standard name you'll need to let it know what to use rather than the default ~/.ssh/id_rsa.

share|improve this answer
    
tried to display the whole log but it's too long but basically the keys match and a connection is made but it says this debug1: Roaming not allowed by server debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey –  user866190 Aug 22 '11 at 16:24
    
That's fine, only the last few lines should be relevant to the failure. That's saying the receiving side will only accept publickey and it fails as none is sent. Did you try the -i option with your key? That should do the trick. Are you using ssh-agent? Or do you have to specify your keys passphrase each time you SSH? –  Aaron Copley Aug 22 '11 at 16:29
    
Have you had any luck sorting this out? –  Aaron Copley Aug 23 '11 at 14:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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