Connecting via SSH key to Juniper

I will give an example of setting up an SSH key connection to Juniper MX.

First, I generated a public key on the Linux server from which I needed to connect:

ssh-keygen -t rsa

Then I looked at the contents of the public key:

cat /root/.ssh/id_rsa.pub

Something like this appeared:

ssh-rsa XXXXXXXXXXXXXXXX root@ixnfo

Then the contents of this key must be specified in the Juniper configuration, for example, the admin user:

edit system login user admin authentication
set ssh-rsa "ssh-rsa XXXXXXXXXXXXXXXX root@ixnfo"
run show system login
commit

Done, now from this Linux server you can connect to Juniper using an SSH key without entering a password.
I needed this for daily configuration backup, in ABillS billing, I will give an example of my script:

#!/bin/bash
scp -P 2222 admin@IP:/config/juniper.conf.gz /srv/tftp/`date +%Y-%m-%d`_0201_nas_99_.conf.gz
chown www-data:www-data /srv/tftp/`date +%Y-%m-%d`_0201_nas_99_.conf.gz

See also my articles:
Juniper MX configuration backup
Juniper MX204 setup

Leave a comment

Leave a Reply