Created
December 2, 2018 15:14
-
-
Save shyamjos/ca64ada022be037d4ce6b48ea6a79972 to your computer and use it in GitHub Desktop.
Generate SSH config from csv or text file in comma separated format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#Sample input file (hosts.csv) | |
#server-new,172.16.158.35,22,deploy | |
#server-db,172.16.158.40,2211,deploy | |
#server-db-old,172.16.158.30,22,admin | |
#server-db-2,172.16.158.32,1111,user | |
cat hosts.csv | while read line | |
do | |
Host=$(echo $line | cut -d ',' -f1) | |
HostName=$(echo $line | cut -d ',' -f2) | |
Port=$(echo $line | cut -d',' -f3) | |
User=$(echo $line | cut -d',' -f4) | |
echo "Host $Host" | |
echo " HostName $HostName" | |
echo " Port $Port" | |
echo " User $User" | |
echo " " | |
echo " " | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment