1. intro

Many Linux servers does not allow to logon as root anymore for obvious security reasons.

Despite many tutorials you can find on the internet, i’m going to show you how easy it is to create or renew your SSH keys.

2. the magic

mkdir -p ~/sshkeys
cd ~/sshkeys/
ssh-keygen -q -f id_rsa -b 2048 -P "" -C "$(date +%d%b%Y)"
mv id_rsa.pub authorized_keys
chmod 400 authorized_keys id_rsa
mkdir -p ~/.ssh
mv ~/sshkeys/id_rsa ~/.ssh/

3. send it to a server as a regular user

rsync -ai authorized_keys srv121.d01.net:.ssh/
Warning: Permanently added 'srv121.d01.net' (ECDSA) to the list of known hosts.
ary@srv121.d01.net's password: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<f+++++++++ authorized_keys

4. config it on the server as root

ssh srv121.d01.net
su - <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
mkdir -p ~/.ssh
cat ~ary/.ssh/authorized_keys > ~root/.ssh/authorized_keys
chmod 400 ~root/.ssh/authorized_keys