I am currently implementing key pair login to my server as following:
generate key pair from my local laptop:
me@macbook:~ $ ssh-keygen -t rsa
transfer pub key from laptop to server:
me@macbook:$ scp ~/.ssh/id_rsa.pub user@myserver.com:~/id_rsa.pub
in the server, add pub key to authorized_keys file
$ cat id_rsa.pub >> ~/.ssh/authorized_keys
And I disabled the password login for ssh.
The problem is that, the key can only used in my laptop to ssh in my server, looks like it is binded with my macbook laptop. That means, if I am with another computer, I would not be able to use that private key to ssh. In worst case, if I lost my laptop, I will be locked, no way to ssh in. (Correct me if wrong, I am confused)
How can I make the private key useable for multiple machines? (like AWS ec2, i can use the .pem file @ anywhere to ssh in)
Thanks.
Below is content of authorized_keys file