How to copy folder from remote server (digital Ocean) to local computer - digital-ocean

I am trying to copy a folder from my digital Ocean server to my computer.
I have successfully connected as root to my server and I have the ssh Public key setup
I use command root#my-server_ip to connect successfully.
When I try to copy a file like
scp -r root#my-server_ip:/file/path/ /where/to/put
I get this error Permission denied (publickey).
I can't figure out what the heck is the issue

Permission denied occurs when the server is not able to validate the incoming connection. You need to provide the path to your identity file (ssh key) explicitly when making a request through scp.
Something like this:
scp -i <path_to_identity_file> -r root#my-server_ip:/file/path/ /where/to/put

Related

Creating a user and adding public key on aws ec2 instance

I've created a user and copied the public key to .ssh/authorized_key for that new user and also I've set the pubkeyauthentication to yes on /etc/ssh/sshd_config after saving the file restarted the sshd service.
When I try to ssh from the new user I am getting error:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic)
Am I missing any step here to ssh from the new user account?
When I check the status for sshd.servive I see error:
AuthorizedKeysCommand /opt/aws/bin/eic_run_authorized_keys xxxx SHA256:84NyibLXFppE4BGIM+1e5iO...status 22
Had the same issue error: AuthorizedKeysCommand /opt/aws/bin/eic_run_authorized_keys ec2-user.
Make sure the file permission is user only (600) in the $HOME/.ssh directory on the SSH client side host.
"error: AuthorizedKeysCommand /opt/aws/bin/eic_run_authorized_keys ...snip... failed, status 22" error #20
FYI
To debug:
sudo tail -f /var/log/secure to monitor the reason why SSH refuses the connection.
Make sure $HOME/.ssh/authorized_key content on EC2 instance is correctly match with your ssh private key in the SSH client host.
Make sure correct private key is being used, use -i option to explicitly specify which key you use.
You might want to check the algorithm you are using to generate the key.
I saw exactly the same error message when using the ECDSA algorithm but fixed the problem by using RSA instead (ssh-keygen -t rsa).
If you want to dig deeper you can try
ssh -Q key
to get a list of supported key types.

Getting permission errors while transferring datasets to an EC2 instance

I am trying to transfer files present on Kaggle, to an EC2 instance. Accoring to this link, the command to be used from Putty is
"scp -i /path/my-key-pair.pem /path/cookies.txt user-name#ec2-xxx-xx-xxx-x.compute-1.amazonaws.com:~".
However, I am getting the following error:
[ec2-user#ip-172-31-32-16 ~]$ scp -i /path/my-key-pair.pem /path/cookies.txt ec2-34-214-179-99.us-west-2.compute.amazonaws.com:~ Warning: Identity file /path/my-key-pair.pem not accessible: No such file or directory. The authenticity of host 'ec2-34-214-179-99.us-west-2.compute.amazonaws.com (172.31.32.16)' can't be established. ECDSA key fingerprint is SHA256:PdEvoAAd7Bc37PbnODNkNiqy/zE2MwoVzCv8jw8McfI. ECDSA key fingerprint is MD5:66:c2:b4:7e:50:a2:a8:67:ec:84:2c:ee:76:02:74:b0. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'ec2-34-214-179-99.us-west-2.compute.amazonaws.com,172.31.32.16' (ECDSA) to the list of known hosts. Permission denied (publickey). lost connection
Apparently This occurs when the key does not have the right permissions. One suggestion I received is to search for chmod 400 equivalent for windows. I did but did not find anything appropriate. Please help

Digital ocean on Laravel Forge - Unable to load key (navicat)

Im pulling my hair out with this one. I've managed to get a site running on Digital Ocean through Forge and also SSH into the server so I know that the SSH keys are setup correctly.
But when trying to connect via Navicat, I keep getting the error "Unable to load key". Does anyone know what this is in reference to or what the problem is.
regards
There is an answer from 2015 on Navicat forum, indicating there could be issue with ssh key support.
If you can connect via ssh, do an ssh tunnel to your server manually:
ssh -v servername -L 3306:127.0.0.1:3306 -N
Afterwards, you connect to remote mysql as it was on your localhost (you should not have one running on 3306, otherwise map to another local port)

How do I connect to aws ec2 server from chromebook using the secure shell extension?

I am trying to connect to my ec2 instance from my chromebook using the secure shell extension but I keep getting the following error:
Loading NaCl plugin... done.
ssh: connect to host (public DNS) port 22: Connection refused
NaCl plugin exited with status code 255.
I have been following the steps on this site but with 0 success.
http://www.mattburns.co.uk/blog/2012/11/15/connecting-to-ec2-from-chromes-secure-shell-using-only-a-pem-file/
Help please.
If you're doing this on your chromebook, you should have developer mode enabled so that you can enter the console and execute Linux commands. Once developer mode is enabled, enter the console with ctrl+alt+t and then type in shell.
First you'll want to change the permissions of your .pem key. The ssh keygen won't run if the permissions aren't restricted enough.
sudo chmod 400 myKeyPair.pem
Next you'll want to generate your own public key with ssh-keygen like mentioned in the other links.
ssh-keygen -y -f myKeyPair.pem > myKeyPair.pub
After this, you'll want to create a file with no extension and the private key pair inside.
touch myKeyPair
After this, copy the contents of the .pem file to the file with no extension, myKeyPair.
sudo cat myKeyPair.pem > myKeyPair
Next you'll want to open up the secure shell extension, which can be found here.
Enter your connection information for your machine and don't forget to specify the port number. When it comes to importing the key pair, select both the myKeyPair.pub and the myKeyPair files using ctrl.
That's it, you should be connected!

How to connect to server with only username and public ssh key?

I want to use a batch file to connect to a amazon server by using the ssh private or public key.
I have tried
open sftp://user:password#example.com/ -hostkey="ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
psftp fred#server.example.com
in the script but I am not able to connect to the server. I am getting this error.
disconnected no supported authentication methods available (server sent publickey)
I am able to connect it from putty. I want a batch file to connect to the server and restart the django project in that.
If I am able to connect then I just need to go the path of my django project and run the command
manage.py runserver
ssh -i PrivateKey.pem username#server.example.com