i want to transfer file from linux to windows from root using scp/pscp commands, but iam getting access denied error - scp

i want to transfer a text file from Linux (centos) to windows using scp/pscp commands from root, but I am getting access denied error when executing scp -r {file name} user#ip:/

Related

Robot Framework - SSH library - Editing a file on remote server

I am writing a test case in Robot Framework where in, I have to either copy the file from the local machine (windows) to the remote server (linux) or create a new one at the location.
I have used multiple sudo su - command to switch users to root user to reach the desired host. As a result of this, I am not able to use Put File Keyword from SSH Library to upload the file. I have reached at the desired folder location by executing the commands with Write keyword.
Since there is no option left (thats what i realize with my limited knowledge on Robot Framework), i started creating a new file with vi <filename> command. I have also reached the INSERT mode of the file, BUT i am not able to edit text into the file.
Can someone please suggest me how can i either
Copy the file from local windows machine to remote linux server AFTER multiple SU commands (Switch User)
Create a new text file and enter the content.
Please See : the new file which is being created / copied is a certificate file. Hence i do not wish to write the entire content of the certificate in my test suite file
The entire test case looks something like this
First Jump1
Log Starting the connection to AWS VM
# Connection to VM with Public Key
Connection To VM ${hostname} ${username}
Send Command sudo su -
Send Command su - <ServiceUser1>
# Reached the Detination server
Send Command whoami
Send Command ss -tln | grep 127.0.0.1:40
# Connecting to Particular ZIP
Send Command sudo -u <ServiceUser2> /usr/bin/ssh <ServiceUser2>#localhost -p <port>
Send Command sudo su -
# Check Auth Certificate
Send Command mosquitto_pub -h ${mq_host} -p ${mq_port} -u ${mq_username} -P ${mq_password}
In the step Check Auth Certificate, the certificate is checked to be present or not, if present -> delete the current certificate and create the new one (either create a new file or upload from local) and if it not there create a new certificate
though it might not be ideal, but was able to achieve what i wanted to do with
echo "content" > newFilename
echo "update content" >> newFileName

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

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