Cannot scp AWS Lightsail instance - Permission Denied - scp

I have a AWS Lightsail Bitnami instance. I am able to ssh using the default keypair. However when I try to scp using that same key I am given a 'Permission denied' response. I have tried scp'ing to /home/bitnami/apps/ and /opt/bitnami/apps. I have also tried changing the permissions of my pem file to 400.
scp -r -i lightsail-key.pem ~/Local\ Sites/myportfolio/app/ bitnami#34.170.81.72:/opt/bitnami/apps

I needed to change the owner of the target folder. I ssh'd into my instance and ran sudo chown bitnami TARGETFOLDER.

Related

Scp file from local to remote server with user password

I'm trying to copy a file from my local machine macosx 10.11.6 to a remote server (digital ocean droplet) ubuntu 18.04 using scp.
I tried
scp -r /path/to/local/file username#ipaddress:/path/to/folder/where/to/copy
and I got permission denied.
I ssh into the server cd /path/to/folder/where/to/copy and test with touch index.txt and got permission denied.
I tried to touch index.txt with sudo which worked after input the password.
I tried install and use sshpas
sshpass -p 'mypassword' scp -r /path/to/local/file username#ipaddress:/path/to/folder/where/to/copy
And I got permission denied again.
What is the correct way to copy that file from local to the remote server passing the user password?
It sounds like your remote server user doesn't have write permissions to your destination directory, that's why the touch fails.
You can either copy the file to somewhere else (your user's home?) or modify the destination folder's permissions with sudo and chmod to allow your user to write to the destination directory.
As mentioned here SSH SCP Local file to Remote in Terminal Mac Os X , I had to do it in two times.
scp -r /path/to/local/file username#ipAddress:/home/username
then
ssh username#ipAddress
sudo mv file path/to/destination/folder

Not able to connect (using ftp and command line with) server via pem file

I have instance id, public DNS IP address, .pem file. I tried to connect to an EC2 instance using FileZilla but each time it fails saying could not authenticate (server: public key sent).
How can I connect using filezilla to EC2 instance?
I have tried putty too but it also gives an error and can't let me log in.
When tried using command line ssh -i My.pem root#ec2-myipaddress.us-west-2.compute.amazonaws.com it also gives error Permission denied (public key).
ssh -i My.pem root#ec2-myipaddress.us-west-2.compute.amazonaws.com
Its give permission issue so first of all run below command
sudo chmod 400 My.pem
After that try to connect with ssh command
and for file transfer use winSCP Tool.
you can check here for more detail
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html
Thanks

Permission Denied (public key)

I'm running a google cloud instance. I'm able to successfully connect to the instance via ssh.
But I'm not able to do the port forwarding to my localhost.
Here's the command I used:
ssh -L 16006:127.0.0.1:8080 username#instance_external_ip
When I run the above command , I get the following error
The authenticity of the host cannot be determined.
username#instance_external_ip : Permission Denied (public key)
How to solve this problem?
I found the answer for this question. The problem I had was that the server did not know the ssh keys. So, I did the following and it worked.
I deleted all the ssh keys in the my local machine and connect to my gcloud instance using the following command. gcloud command creates the ssh keys automatically and it transfers to the cloud ssh keys automatically. So, no need to manually copy paste the keys.
gcloud compute --project "project_name" ssh --zone "zone_name" "instance_name"
After this I connected to my instance using ssh. Before doing if you try to ssh tunnel , as the server won't be aware of the localhost, it will say permission denied on running ssh -L .....
Therefore, instead of directly connecting through ssh -L ... , connect along with ssh-key file stored in .ssh directory. Use the following command.
ssh -i ~/.ssh/google_compute-engine -L <ur localhost port number>:127.0.0.1:<remote_host_port> username#server_ip

copying file from local machine to Ubuntu 12.04 returning permission denied

How to I grant myself permission to transfer a .crt file from my local machine to the aws ubuntu 12.04 server?
I am using the following command from my machine and receiving a permission denied response.
scp -i /Users/me/key_pair.pem /Users/me/ssl-bundle.crt ubuntu#ec2-50-150-63-20.eu-west-1.compute.amazonaws.com:/etc/ssl/certs/
I am following comodo's instruction. Refer to the heading Configure your nginx Virtual Host from the link. I have not set anything up with regards to permission as user. This is a little new to me and will appreciate further sources of information.
I changed the permission of the path on the server and transferred the file!
With reference to File Permissions , I gave the /etc/ssl/certs/ path the "Add other write & execute" permission by this chmod command when ssh'd into the Ubuntu server:
sudo chmod o+wx /etc/ssl/certs/
Then, on my local machine, the following command copied a file on my directory and transferred it to destination:
scp -i /Users/me/key_pair.pem /Users/me/ssl-bundle.crt ubuntu#ec2-50-150-63-20.eu-west-1.compute.amazonaws.com:/etc/ssl/certs/
It is the write permission you need, and depending on your use case, use the appropriate chmod command.
Simplest way to transfer files from local to ec2 (or) ec2 to local by FileZila.
You can connect with your instance by using Filezila, then transfer files from local to server and vice-versa.

permission denied while uploading file to EC2

I have installed apache webserver apache in linux ,I used following code to upload a file, but i get permission denied
scp -i adjmp.pem index.html ec2-user#ec2-50-17-88-33.compute-1.amazonaws.com:/var/www/html/hi
How can i upload a file to EC2 ?
You most likely need to change the filesystem permissions. This is usually done using the chmod command. You may also need to modify file ownership (using the chown command).
If you need help with the exact steps, you can provide the output of the following two commands and I will try to help:
sudo ls -al /var/www/html/hi
id