Monday, March 18, 2013

Recreating user SSH keys

Login as root then "su -" as the user in question.

[root@wrk01~]# su - john.smith

cd to the user ".ssh" hidden directory
[john.smith@wrk01~]$ cd .ssh

delete any previous "id" files and "Authorized_keys" file.
[john.smith@wrk01 .ssh]$ rm id_rsa
[john.smith@wrk01 .ssh]$ rm id_rsa.pub
[john.smith@wrk01 .ssh]$ rm authorized_keys

Now generate the new "id_rsa" key files.
[john.smith@wrk01 .ssh]$ ssh-keygen -t rsa

Now copy the "id_rsa.pub" to the "Authorized_keys" file.
[john.smith@wrk01 .ssh]$ cp id_rsa.pub authorized_keys

List all new files and their proper permissions.
[john.smith@wrk01 .ssh]$ ls -al
-rw------- id_rsa
-rw-r----- id_rsa.pub
-rw-r----- authorized_keys
-rw-r----- known_hosts