-2

I am new to programming and am trying to ssh to my server as that may be needed later to edit code.

My ~/.ssh/id_rsa.pub is

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3UP7ryN33fuzwg5wfXSsTDtcRc+jTsrU2+IYI0yrGqPZ7F4+LesO+1/delLvQuhr8O+YJPgAZK6mRoY+ruWPEf/hGsJkrR76kNeOSFkXP/QgSN7aWPhgRFs0EaUk+fgHcri1mOOgxcNto7Mwo8U+YuuMf3CMxMqBcWKccPvPSNMmL91cs56pTM6VXP+rNYBGEFiEqjZdYrUncICmgOO2fIgpcLOIBYsgBcWdl+vycc0oMhLtRPy6ALgzujI3FSMhRxwi8Oy0UjCHNJowcb+XFZrDk8qRUucp1/IYGXBgjS7jJVTejseIKZvnf1qEyRYY8p7pltfqrGKdPNRT5zSun mrinmaykalita@MacBook-Pro-77.local

and

my ~/.ssh/known_hosts has an entry as

173...** ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMIkfmRuMEdyptRu11rW+3qlokDq3B5HDruYGow1fJTTQrPhL7YLAabAek97jChU09VcdBzr2x8+v3HsUfT6Blc=

What should I use for ***** in

ssh-copy-id -i ***** root@173...** to send public key to that server so I can ssh after that? And what is the significance of the other?

I am a newbie, so a dumb question.

Please help.

Thanks and Regards

Mike K
  • 1
  • 4
  • Dude, don't post keys, or IPs here. – LukasS Aug 06 '18 at 01:17
  • 1
    @LukasS am not sure how posting public keys can be harm to me, dude. – Mike K Aug 06 '18 at 01:54
  • How posting contents of a key will help your case? Copy the public key (I assume it's your pc) to your server's ~/.ssh/authorized_keys and chmod it 0600 (.ssh/ should be 0700) - you're good to go. And this isn't programming - just utilities :). – LukasS Aug 06 '18 at 02:01
  • @LukasS but how will you copy to my server in 1st place without ssh entry? That requires that the public key be put there by someone who has access to the server; not anyone ;) – Mike K Aug 06 '18 at 02:29
  • I assume you know how to login to your server (you have the credentials). You can use whatever protocol that allows you to modify files (ftp, sftp, ftp over ssh...) it doesn't matter. Otherwise what are we discussing here? – LukasS Aug 06 '18 at 02:33
  • @LukasS precisely; I am not able to login to my server because I have lost my credentials. Another way to authenticate is via ssh that requires that the server hold the public key as mine in its authorized_keys but I am not able to ensure that itself. – Mike K Aug 06 '18 at 02:41
  • Your only two options is to find/acquire private key from the server and use that one to log in or talk to the hosting company if they set up the server for you, so they can reset password for your user (they usually keep access to servers in case they need to maintenance it). Depends on the company. Otherwise, you're out of luck... – LukasS Aug 06 '18 at 02:45
  • I have the .pem private key. how may I use that to login? – Mike K Aug 06 '18 at 02:48
  • .pems are used for SSL (so HTTPS not SSH), you need ssh private key, contents of (usually): ~/.ssh/id_rsa – LukasS Aug 06 '18 at 02:52
  • Please move your question to [su] (delete here, re-post there). It's [off-topic here](//stackoverflow.com/help/on-topic). – Martin Prikryl Aug 06 '18 at 07:13

1 Answers1

0

What should I use for ***** in ssh-copy-id -i ***** root@173...46 to send public key to that server so I can ssh after that?

Use a path to the public key file:

ssh-copy-id -i $HOME/.ssh/id_rsa.pub root@173...46 to send public key to that server so I can ssh after that?

Be careful with the access modes of files and directories (as said in a comment): as a general rule, do not set group or world access or modification rights to the corresponding inodes.

Alexandre Fenyo
  • 4,526
  • 1
  • 17
  • 24