4

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

user866190
  • 209
  • 1
  • 2
  • 5

1 Answers1

3

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.

Aaron Copley
  • 12,525
  • 5
  • 47
  • 68
  • 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