FastHandle is fast operation tools for infrastructure configurations and tests.
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
fhscripts:create:create_ssh_keypair.sh.html [2017/12/25 01:20] kurihara |
fhscripts:create:create_ssh_keypair.sh.html [2018/03/29 00:06] (current) kurihara |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ~~NOTOC~~ | ||
[[: | [[: | ||
- | ====== | + | ====== |
+ | $FHHOME/ | ||
- | ===== How to use ===== | + | {{INLINETOC}} |
+ | \\ | ||
+ | |||
+ | ===== How to use create_ssh_keypair.sh===== | ||
<sxh bash toolbar: | <sxh bash toolbar: | ||
$ create_ssh_keypair.sh | $ create_ssh_keypair.sh | ||
+ | </ | ||
+ | |||
+ | \\ | ||
+ | == Example Output == | ||
+ | |||
+ | <sxh bash toolbar: | ||
+ | $ ./ | ||
+ | Generating public/ | ||
+ | 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: | ||
+ | The key's randomart image is: | ||
+ | +--[ RSA 2048]----+ | ||
+ | | | ||
+ | | o. = . | | ||
+ | | oo * | ||
+ | | =.o * . | | ||
+ | | o S o + | | ||
+ | | = + | | ||
+ | | o + | | ||
+ | | | ||
+ | | | | ||
+ | +-----------------+ | ||
+ | ========================================================== | ||
+ | Check | ||
+ | ========================================================== | ||
+ | |||
+ | # ls -ltrh id_rsa.user01.test-server-01* |tail -n 2 | ||
+ | -rw-r--r-- 1 root | ||
+ | -rw------- 1 root | ||
+ | |||
</ | </ | ||
\\ | \\ | ||
- | ===== Script | + | ===== create_ssh_keypair.sh |
+ | |||
+ | $FHHOME/ | ||
<sxh bash toolbar: | <sxh bash toolbar: | ||
Line 23: | Line 60: | ||
if [ " | if [ " | ||
- | echo 'ERROR: | + | cat << @ |
- | echo 'How to use:' | + | ERROR : argument isn't correct. |
- | echo 'create_ssh_keypair.sh | + | How to use: |
- | exit 1 | + | create_ssh_keypair.sh |
+ | @ | ||
+ | exit 1 | ||
fi | fi | ||
Line 32: | Line 71: | ||
HOST=$2 | HOST=$2 | ||
- | ssh-keygen -t rsa -b 4096 -C " | + | OUTFILE=id_rsa." |
+ | 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` | ||
- | cat << @ | + | ssh-keygen |
- | ========================================================== | + | |
- | Check | + | |
- | ========================================================== | + | |
- | + | ||
- | # ls -ltrh id_rsa* |tail -n 2 | + | |
- | `ls -ltrh id_rsa* |tail -n 2` | + | |
- | + | ||
- | @ | + | |
- | </ | + | |
- | \\ | ||
- | ===== Example Output ===== | ||
- | <sxh bash toolbar: | + | cat << @ |
- | $ create_ssl_csr_key.sh 192.168.0.15 | + | |
- | Generating a 2048 bit RSA private key | + | |
- | ....................................+++ | + | |
- | .....+++ | + | |
- | writing new private key to ' | + | |
- | ----- | + | |
========================================================== | ========================================================== | ||
Check | Check | ||
========================================================== | ========================================================== | ||
- | # ls -lh 192.168.0.15* | + | # ls -ltrh ${OUTFILE}* |tail -n 2 |
- | -rw-r--r-- 1 root root 1013 Dec 19 01:02 192.168.0.15.csr | + | `ls -ltrh ${OUTFILE}* |
- | -rw-r--r-- 1 root root 1.7K Dec 19 01:02 192.168.0.15.key | + | |
- | + | ||
- | #openssl req -text -in 192.168.0.15.csr | + | |
- | Subject: C=JP, ST=Tokyo, L=Shibuya-ku, O=Example, Inc., OU=IT, CN=192.168.0.15 | + | |
+ | @ | ||
</ | </ | ||
+ | |||
+ | \\ | ||
+ | \\ | ||
+ | <WRAP box 90%> | ||
+ | <catlist ..: -noAddPageButton -smallHead -sortAscending | ||
+ | </ |
My Sites
SNS
Copyright (c) 2025 FastHandle - IT Operations Examples All Rights Reserved.