跳至內容

RE:copy files from ec2

0

hi. i can ssh to ec2 using putty, but unable to copy files, permission denied. if i use sudo su then only can view file, but use winscp cannot. any way?

已提問 1 年前檢視次數 170 次
2 個答案
1

Hello,

When you log in using a user, you can access only directories or files that are owned by or have access to that user. If you try to access any other folder like root "/", you will get a permission denied error. So if you want to access a folder, ensure that the folder already has access for the user you are trying to log in with.

[+] https://stackoverflow.com/questions/28261503/get-permission-to-work-with-files-on-my-amazon-ec2-ubuntu-server-using-ftp-winsc

已回答 1 年前
專家
已審閱 1 年前
專家
已審閱 1 年前
0

Hello. You can download the file by copying it to a location accessible to the user who logged in then changing the permissions with the chmod command.

專家
已回答 1 年前
  • hi how to do that?

  • how to do that specifically?

  • Suppose you are logged in as an ec2-user and want to download /var/log/nginx/access.log. You can download the file in /home/ec2-user/access.log by typing the following command.

    sudo su -
    cp /var/log/nginx/access.log /home/ec2-user/access.log
    chmod 755 /home/ec2-user/access.log
    

    Or you can use chown to change the owner.

    sudo su -
    cp /var/log/nginx/access.log /home/ec2-user/access.log
    chown ec2-user: /home/ec2-user/access.log
    

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。