-1

I want to change my remote server SSH. Currently I login through a .pem file

ssh -l ubuntu -i .ssh/myfile.pem XX.XX.XXX.XXX

I tried to find how to change that access key but I found only that methor :

ssh-keygen -t rsa -b 2048
cp id_rsa.pub authorised_keys 
scp authorized_keys ubuntu@XX.XX.XXX.XXX:/home/ubuntu/.ssh

I see no .pem file generated, plus how can I connect now ? I want to make sure before I do anything so I don't lose ability to connect via SSH. Should I remove the old key with :

ssh-keygen -R hostname

If yes, when ? after or before the scp ? if after this will remove both keys, if before then I wouldn't be able to perform scp !!! I am a bot confused. I see no .pem file in my remote, the pem file is only in my local .ssh folder. in remote .ssh I see :

enter image description here

user2997418
  • 648
  • 1
  • 8
  • 22

1 Answers1

2

With "ssh-keygen" command you generate a pair of public and private keys (by default stored in $HOME/.ssh).

Then you copy the public key in your remote server, and the private key in your local client (with permissions 0600). You can use "ssh-add" command to add the private key to the authentication agent to be able to connect to the remote server.

aicastell
  • 2,182
  • 2
  • 21
  • 33
  • how do I delete the old SSH key in my remote? – user2997418 Mar 30 '17 at 13:21
  • If I just add a new public key to my remote then both new and old connection will work ? I want to delete the old , should I run ssh-keygen -R hostname ? – user2997418 Mar 30 '17 at 13:23
  • Use ssh verbose flag (-v) or strace to discover what's happening when connecting with ssh. In my remote server there is a /etc/ssl/certs directory with a lot of .pem files, but take care with that. – aicastell Mar 30 '17 at 14:33
  • I found a lot !! is there a way toi know the right file ? – user2997418 Mar 30 '17 at 14:45