简体   繁体   中英

How to upload a lib for Tomcat in Amazon EC2

I need to upload a lib to my Tomcat folder (in an EC2 instance). What I've always done is:

scp -r -i /home/path_to_key/key.pem /home/path_to_file/file.jar  ec2-user@my_address.compute.amazonaws.com:/home/ec2-user

This works if I upload files in the "user" folder (or its subfolders). What if i want to upload a file in /opt/tomcat7/lib/ ? I receive this error:

scp: /opt/tomcat7/lib/file.jar: Permission denied

Anyone can help me? Thanks, Andrea Negri

EDIT:

totale 140
drwxr-xr-x 10 tomcat7 tomcat7           4096 17 lug 00:30 .
drwxr-xr-x  5 root    root              4096  6 gen  2012 ..
-rw-r--r--  1 tomcat7 tomcat7             18 28 lug  2011 .bash_logout
-rw-r--r--  1 tomcat7 tomcat7            176 28 lug  2011 .bash_profile
-rw-r--r--  1 tomcat7 tomcat7            124 28 lug  2011 .bashrc
drwxr-xr-x  2 tomcat7 tomcat7           4096 17 lug 00:30 bin
drwxr-xr-x  3 tomcat7 tomcat7           4096 18 ago 15:35 conf
drwxr-xr-x  2 tomcat7 tomcat7           4096 17 lug 00:30 endorsed
-rw-r--r--  1 tomcat7 tomcat7            121 28 lug  2011 .kshrc
drwxr-xr-x  2 tomcat7 tomcat7           4096 17 lug 00:30 lib
-rw-r--r--  1 tomcat7 tomcat7          56797 20 nov  2011 LICENSE
drwxrwxr-x  2 tomcat7 elasticbeanstalk  4096 18 ago 18:01 logs
-rw-r--r--  1 tomcat7 tomcat7           1192 20 nov  2011 NOTICE
-rw-r--r--  1 tomcat7 tomcat7           8824 20 nov  2011 RELEASE-NOTES
-rw-r--r--  1 tomcat7 tomcat7          10597 20 nov  2011 RUNNING.txt
drwxr-xr-x  2 tomcat7 tomcat7           4096 17 lug 00:30 temp
drwxr-xr-x  3 tomcat7 tomcat7           4096 18 ago 15:39 webapps
drwxr-xr-x  3 tomcat7 tomcat7           4096 18 ago 15:35 work

You need to set the proper privileges so the ec2-user can write to the target directory. If you post the output of these two commands, I will try to help you:

id
sudo ls -al /opt/tomcat7

Edit: Based on your output, I think the proper thing to do would be to add the ec2-user to the "tomcat7" group, then grant that group write access to the directory:

sudo usermod -a -G tomcat7 ec2-user
sudo chmod -R g+w /opt/tomcat7

Here has a explanation with another solution for your problem Amazon Ec2 FTP Write Permission

"The ec2-user don't have permission to write files in /var/lib/tomcat6/webapps/. Only root user can do so. You have two ways here to do so:

1) Copy files to /home/ec2-user/ using filezilla. Now SSH into linux machine through putty. Change to root user using command sudo -s. Then copy file from /home/ec2-user to /var/lib/tomcat6/webapps/ using command cp -i RealEstateERP.war /var/lib/tomcat6/webapps/.

2) SSH into linux machine through putty.Change to root user using command sudo -s.Provide write permission to all users on /var/lib/tomcat6/webapps/ using command chmod 777 /var/lib/tomcat6/webapps/. Then copy files to directory directly from filezilla."

Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM