0

I did login into amazon server on terminal by ssh -i /path/to/pem_file.pem [email protected]. It was working fine but there are too many log files into ec2/ folder so i tried to delete them by using the command (find . -file_name_to_delete_all_series"*" -delete) and suddenly i noticed all files deleted and now i am not able to connect to server by using above ssh login command and getting this error "Permission denied (publickey)".

when i am hitting it with -v then its showing

$ ssh -i /path/pem.pem [email protected] -v

OpenSSH_6.7p1 Ubuntu-5ubuntu1.4, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to ec2-my_server port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /pem_file.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file /pem_file.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.7p1 Ubuntu-5ubuntu1.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr [email protected] none
debug1: kex: client->server aes128-ctr [email protected] none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 34:77:b9:f0:87:6b:e8:c7:31:90:92:7c:a3:b5:4b:58
debug1: Host 'ec2-server.amazonaws.com' is known and matches the ECDSA host key.
debug1: Found key in /home/apps/.ssh/known_hosts:1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /pem_file.pem
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

i think all files has been deleted by ec2/ folder thats why i am facing this error.

Any help would be appreciated.

0

2 Answers 2

0

what do you mean for find . -file_name_to_delete_all_series"*" -delete

I don't find any option "-file_name_to_delete_all_series" ... do you mean something like: -name name-of-the-files-I-want-to-delete"*"

using the command find with a "." (dot) you forced it to search within your working directory. Can you please be more specific about which log files you were trying to delete ?

Unfortunately it seems like you have deleted the public key ... hence ... no ssh possible !! Cheers Francesco

4
  • Actually i wanted to delete multiple files by same name from server like ( file.20001,file.20002......20100..) thats y i tried a command on server into ec2/ folder i.e. . -file"" -delete i got this command by google to delete too many files by same name... yes this one -name name-of-the-files-I-want-to-delete"" but i typed it as -name-of-the-files-I-want-to-delete"*" Jul 21, 2017 at 9:22
  • so I guess there was some "misstype" and you deleted all the files in ec2/ ... next time before applying "-delete" to find, just run the find command and check if the output is what you expect. As per now ... if you still have a "logged ssh session" than you can eventually create a new keypair, otherwise ... I think you need to ask to AWS support ! Jul 21, 2017 at 10:28
  • If i have deleted the public key from server then now how can i connect to the server ? Jul 24, 2017 at 8:28
  • As I said you need to ask to AWS support. There is no workaround that I know. Jul 25, 2017 at 10:02
0

This might be because the public key file has been deleted on the target server no ? Then ssh process can't identifiy you that's why commands fails...

Trying private key: /pem_file.pem

Do this file exists on the target server ?

2
  • i think it doesn't exist. how can i confirm ? Jul 24, 2017 at 8:25
  • I've tried checking on one of my server, it seems that the public key doesn't exists on your local server cf message : debug1: key_load_public: No such file or directory debug1: identity file /pem_file.pem type -1 The local server doesn't find your local public key file
    – k4cy
    Jul 24, 2017 at 12:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .