Sponsored Content
Top Forums UNIX for Advanced & Expert Users help with private keys (blocs) extraction from file Post 302506199 by LivinFree on Friday 18th of March 2011 08:56:24 PM
Old 03-18-2011
What is your input filename and expected output filename set?

As a proof of concept, assume I put your example in "tmp.in" and ran this script:
Code:
#! /bin/bash

declare i=1
while read line; do 
        [[ "$line" =~ "BEGIN" ]] && exec >tmp.${i} 
        printf '%s\n' "$line"
        [[ "$line" =~ "END" ]] && ((i++))
done <tmp.in

I end up with tmp.1 through tmp.4, each with it's own key. Newlines don't matter. If I put all of one key on it's own line, it still works.

Whoops, quick edit - fixed bug that created extraneous empty file

Last edited by LivinFree; 03-18-2011 at 10:02 PM..
This User Gave Thanks to LivinFree For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

arrow keys / special keys

how to use the arrow keys in shell scripting. is there any special synatax / command for this. i just want to use the arrow keys for navigation. replies appreciated raguram R (3 Replies)
Discussion started by: raguramtgr
3 Replies

2. UNIX for Advanced & Expert Users

SSH public and private keys

Firstly, i apologise if i have posted in a wrong section of the forum. Please let me know which is the correct section my post should go to. I have to SCP a file from one server(server A) to another (server B). I read around that a secure way is to use public and private keys. Assuming my... (2 Replies)
Discussion started by: new2ss
2 Replies

3. UNIX for Dummies Questions & Answers

ssh public/private Keys

Hello, I have an issue with an outside party trying to deliver a file to our server via SFTP. I have setup the .ssh directory under the home directory for the user account that is being used and setup the authorized_keys file with correct permissons etc for .ssh directory and file. We... (2 Replies)
Discussion started by: richo king
2 Replies

4. HP-UX

Problem - Creating SSH Public/Private keys. Please help.

HI, I'm trying to create SSH public/private keys using following command. hp023:/users/vikram> ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/users/vikram/.ssh/id_rsa): rsa Enter passphrase (empty for no passphrase): Enter same passphrase... (9 Replies)
Discussion started by: vickramshetty
9 Replies

5. Solaris

ssh private keys stored on home server

Where in the world are the ssh private keys stored on the home server? I know the public keys are renamed to authorized_keys under the /export/home//.ssh directory on the remote server. (1 Reply)
Discussion started by: jastanle84
1 Replies

6. UNIX for Advanced & Expert Users

openssh 5.3 needs password vs. 4.3 using private keys

Hello, I just installed a bran new Centos 6.2 including openssh 5.3. On older servers I installed older Linux including openssh 4.3, I am using keygen with private/public keys to log root on all servers (in a LAN) without typing password each time. To do this, of course, I have my local... (4 Replies)
Discussion started by: epoins
4 Replies

7. Shell Programming and Scripting

Shell script for SFTP using Public and private keys

Hi all, I needed a shell script for file transfering using public/private keys for authentication. Could you please help me out on this? A procedure to write a shell script is enough. Thanks in advance. Regards. Vidya N (8 Replies)
Discussion started by: Vidya N
8 Replies

8. Shell Programming and Scripting

SFTP - Private and Public keys

Hi All, I have a query....say on server A, I have generated the Private and Public keys and shared the public key with server B. Now i can surelyconnect(without password) from server A to server B..... but can i similarly connect from server B to server A as well Regards (1 Reply)
Discussion started by: Arpit Narula
1 Replies

9. Shell Programming and Scripting

sftp using private and public keys

hi guys , i have few files i have to do sftp, the public and private key work like a magic , no problem at all the syntax is as below sftp -0 identityfile=~/ure/blsl/loc2/.ssh/id_rsa_ssh1 ssh1@remote >log_dir/file.timestamp<<end lcd folder cd folder put * quit end ================ my... (3 Replies)
Discussion started by: rockymayavia
3 Replies

10. Shell Programming and Scripting

FILE_ID extraction from file name and save it in CSV file after looping through each folders

FILE_ID extraction from file name and save it in CSV file after looping through each folders My files are located in UNIX Server, i want to extract file_id and file_name from each file .and save it in a CSV file. How do I do that? I have folders in unix environment, directory structure is... (15 Replies)
Discussion started by: princetd001
15 Replies
PKI --KEYID(1)							    strongSwan							    PKI --KEYID(1)

NAME
pki --keyid - Calculate key identifiers of a key or certificate SYNOPSIS
pki --keyid [--in file] [--type type] [--debug level] pki --keyid --options file pki --keyid -h | --help DESCRIPTION
This sub-command of pki(1) calculates key identifiers of private keys and certificates. OPTIONS
-h, --help Print usage information with a summary of the available options. -v, --debug level Set debug level, default: 1. -+, --options file Read command line options from file. -i, --in file Input file. If not given the input is read from STDIN. -t, --type type Type of input. One of rsa-priv (RSA private key), ecdsa-priv (ECDSA private key), pub (public key), pkcs10 (PKCS#10 certificate request), x509 (X.509 certificate), defaults to rsa-priv. EXAMPLES
Calculate key identifiers of an RSA private key: pki --keyid --in key.der subjectKeyIdentifier: 6a:9c:74:d1:f8:89:79:89:f6:5a:94:e9:89:f1... subjectPublicKeyInfo hash: 6e:55:dc:7e:9c:a5:58:d9:5b:e3:c7:13:14:e1... Calculate key identifiers of an X.509 certificate: pki --keyid --in cert.der --type x509 subjectKeyIdentifier: 6a:9c:74:d1:f8:89:79:89:f6:5a:94:e9:89:f1... subjectPublicKeyInfo hash: 6e:55:dc:7e:9c:a5:58:d9:5b:e3:c7:13:14:e1... SEE ALSO
pki(1) 5.1.1 2013-07-31 PKI --KEYID(1)
All times are GMT -4. The time now is 01:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy