gaggina
gaggina

Reputation: 5425

Ec2 issue in uploading a file via scp

I'm trying to upload a file to my new ec2 vps without any luck.

I'm able to connect via ssh without any problem.

When I try to upload my shell says:

scp -v -i ~/.ssh/maurospage.pem wp-config.php [email protected]:/var/www/blog
Executing: program /usr/bin/ssh host ec2-54-247-43-158.eu-west-1.compute.amazonaws.com, user ubuntu, command scp -v -t -- /var/www/blog
OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /Users/mauromarano/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to ec2-54-247-43-158.eu-west-1.compute.amazonaws.com [54.247.43.158] port 22.
debug1: Connection established.
debug1: identity file /Users/mauromarano/.ssh/maurospage.pem type -1
debug1: identity file /Users/mauromarano/.ssh/maurospage.pem-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 1c:58:69:51:4a:5e:60:4a:a1:39:c8:03:55:cb:f9:10
debug1: Host 'ec2-54-247-43-158.eu-west-1.compute.amazonaws.com' is known and matches the RSA host key.
debug1: Found key in /Users/mauromarano/.ssh/known_hosts:7
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
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
debug1: Offering RSA public key: /Users/mauromarano/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/mauromarano/.ssh/maurospage.pem
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
Authenticated to ec2-54-247-43-158.eu-west-1.compute.amazonaws.com ([54.247.43.158]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = it_IT.UTF-8
debug1: Sending env LC_CTYPE = it_IT.UTF-8
debug1: Sending command: scp -v -t -- /var/www/blog
Sending file modes: C0777 3504 wp-config.php
Sink: C0777 3504 wp-config.php
scp: /var/www/blog/wp-config.php: Permission denied

MacBook-Pro-di-Mauro: ~/Desktop                                                         
→ debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 2672, received 2304 bytes, in 0.7 seconds
Bytes per second: sent 3996.1, received 3445.7
debug1: Exit status 1

ls -l of the folder in with I'm trying to copy the file (a wp folder)

ubuntu@ip-10-227-45-167:/var/www/blog$ ls -l
total 192
-rwxrwxrwx 1 ubuntu root   395 Jan  8  2012 index.php
-rwxrwxrwx 1 ubuntu root   408 Dec 14 09:21 LEGGIMI.txt
-rwxrwxrwx 1 ubuntu root 19929 May  6  2012 license.txt
-rwxrwxrwx 1 ubuntu root 24880 Dec 14 09:21 licenza.html
-rwxrwxrwx 1 ubuntu root  8946 Dec 14 09:21 readme.html
-rwxrwxrwx 1 ubuntu root  4663 Nov 17 15:11 wp-activate.php
drwxrwxrwx 9 ubuntu root  4096 Dec 14 09:21 wp-admin
-rwxrwxrwx 1 ubuntu root   271 Jan  8  2012 wp-blog-header.php
-rwxrwxrwx 1 ubuntu root  3522 Apr 10  2012 wp-comments-post.php
-rwxrwxrwx 1 ubuntu root  3737 Dec 14 09:21 wp-config-sample.php
drwxrwxrwx 5 ubuntu root  4096 Dec 14 09:21 wp-content
-rwxrwxrwx 1 ubuntu root  2718 Sep 23 16:57 wp-cron.php
drwxrwxrwx 9 ubuntu root  4096 Dec 14 09:21 wp-includes
-rwxrwxrwx 1 ubuntu root  1997 Oct 23  2010 wp-links-opml.php
-rwxrwxrwx 1 ubuntu root  2408 Oct 26 19:40 wp-load.php
-rwxrwxrwx 1 ubuntu root 29310 Nov 30 13:40 wp-login.php
-rwxrwxrwx 1 ubuntu root  7723 Sep 25 05:26 wp-mail.php
-rwxrwxrwx 1 ubuntu root  9899 Nov 22 09:52 wp-settings.php
-rwxrwxrwx 1 ubuntu root 18219 Sep 11 12:27 wp-signup.php
-rwxrwxrwx 1 ubuntu root  3700 Jan  8  2012 wp-trackback.php
-rwxrwxrwx 1 ubuntu root  2719 Sep 11 20:11 xmlrpc.php

I've tried to chmod 777 myfile on my computer and I did chmod -R 777 * inside the blog folder on my ec2 instance. Nothing changed.

Where I'm going wrong?

Upvotes: 0

Views: 662

Answers (2)

gribbs
gribbs

Reputation: 1

If this is killing anyone else, try using a tilde (~) instead of the root directory (/)

i.e. instead of in this example:

scp -v -i ~/.ssh/maurospage.pem wp-config.php [email protected]:/var/www/blog

try...

 scp -v -i ~/.ssh/maurospage.pem wp-config.php [email protected]:~

..then just connect to your instance as per the connect steps in the ec2 management console as you normally would and move the files to the var/www/html directory as sudo

Upvotes: 0

datasage
datasage

Reputation: 19563

The parent folder lacks the correct permissions. Scp cannot create a new file in your current folder. You probably want to fix your permissions to not use 777 for all files.

Upvotes: 1

Related Questions