FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


Sidebar


Top     SiteMap

Manager Server

Target Server

$FHHOME/bin/xxx.sh | xxxx.exp













.

Action disabled: source
fhscripts:create:create_ssh_keypair.sh.html



FastHandle Scripts

Script for Creating SSH Keypar with one-line

How to use create_ssh_keypair.sh

$ create_ssh_keypair.sh  user01  test-server-01


Example Output

$ ./create_ssh_keypair.sh user01  test-server-01
Generating public/private rsa key pair.
Your identification has been saved in id_rsa.user01.test-server-01.
Your public key has been saved in id_rsa.user01.test-server-01.pub.
The key fingerprint is:
a4:f9:99:44:ab:53:d7:09:13:cb:de:10:43:e8:54:f5 user01@test-server-01
The key's randomart image is:
+--[ RSA 2048]----+
|         +*..    |
|        o. = .   |
|       oo *   E  |
|       =.o * .   |
|      o S o +    |
|       = +       |
|      o +        |
|       .         |
|                 |
+-----------------+
==========================================================
Check
==========================================================

# ls -ltrh  id_rsa.user01.test-server-01* |tail -n 2
-rw-r--r-- 1 root       root        403 Jan  1 01:06 id_rsa.user01.test-server-01.pub
-rw------- 1 root       root       1.7K Jan  1 01:06 id_rsa.user01.test-server-01


create_ssh_keypair.sh

$FHHOME/bin/create_ssh_keypair.sh

#!/bin/bash
#===============================================
# create_ssh_keypair.sh
#
# How to use
#     create_ssh_keypair.sh   user01  test-server-01
#===============================================

if [ "$#" -ne 2 ] ; then
cat << @
ERROR : argument isn't correct.
How to use:
  create_ssh_keypair.sh  user01 test-server-01
@
exit 1
fi

USER=$1
HOST=$2

OUTFILE=id_rsa."${USER}"."${HOST}"

test -f ${OUTFILE} && mv ${OUTFILE} ${OUTFILE}.`date +%Y%m%d_%H%M`
test -f ${OUTFILE}.pub && mv ${OUTFILE}.pub ${OUTFILE}.pub.`date +%Y%m%d_%H%M`

ssh-keygen -t rsa -b 2048 -C "${USER}@${HOST}"  -N "" -f ${OUTFILE}


cat << @
==========================================================
Check
==========================================================

# ls -ltrh  ${OUTFILE}* |tail -n 2
`ls -ltrh ${OUTFILE}* |tail -n 2`

@






fhscripts/create/create_ssh_keypair.sh.html.txt ยท Last modified: 2018/03/29 00:06 by kurihara