Have a Question?
< All Topics
Print

Add SSH Key to host – Script

Add SSH key to Host - Bash Script


#!/bin/bash
# Add SSH key to another system, just provide login and IP of host
# Author : WeeBo
figlet “Add SSH Key”
read -p ‘Username: ‘ uservar
read -p ‘Host IP: ‘ ipvar
echo
echo Thank you $uservar
cat ~/.ssh/id_rsa.pub | ssh $uservar@$ipvar ‘cat >> ~/.ssh/authorized_keys’

Table of Contents