SSH Key Authentication Generator

2065 pts.
Tags:
Bash
IT Scripts
Linux
SSH
Script Name: SSH Key Authentication Generator Language: Bash Purpose: Automate generation of SSH key files (id_rsa & id_rsa.pub for example), for use with passwordless SSH authentication. Notes: This is a modified version of a script I have on my blog, http://www.itknowledgeexchange.com/security-admin/ (direct link: http://itknowledgeexchange.techtarget.com/security-admin/bash-script-for-ssh-key-generation/ ) as I feel the automated version is a lot more resourcesful. #!/bin/bash # Make sure input is not printed to screen (since we are typing in a password after all) stty -echo read -p "Passphrase: " pp stty echo # ssh-keygen prohibits passphrases < 4 characters if [ "${#pp}" -lt 4 ]; then     echo -e "nPassphrase must be greater than 4 characters."     exit 1 fi # man ssh-keygen specifies that for RSA, 2048-bit keys are considered efficient. bits=2048 # Debatable whether DSA or RSA is really more secure here, but RSA is more of the standard when it comes to this enc="rsa" # Default path where all keys are stored kf="$HOME/.ssh/id_$enc" # Check to see if the file exists first (if so, delete it) echo -n "Checking to see if $kf exists (deleting if so)..." if [ -e "$kf" ]; then     rm -rf $kf fi echo -e -n "done.nGenerating a $bits bit $enc key file for SSH ($kf)..." ssh-keygen -q -b $bits -t $enc -N $pp -f "$kf" if [ -e "$kf" ]; then     echo "done." else     echo "error." fi exit 0 [/pre]

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Eric Hansen
    [...] (almost) purely automated script can be found here: http://itknowledgeexchange.techtarget.com/itanswers/ssh-key-authentication-generator/ Underneath the cut, you’ll see the less-automated [...]
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following