Skip to contentSkip to conversation

Add ssh client module code

PATCH In review Dave Young 4 participants 11 messages Dec 23, 2011 – Dec 26, 2011 5 messages not in the archive

lore
Share & tools
lore

Dave Young

author
#0 lore raw

PATCH 4/4 Add ssh client module code

Add ssh-client module, which support ssh key mode and interactive mode. with --sshkey option you can provide the ssh key to be installed

Usage:
1. sshkey mode:
transfer your public key to remote machine with ssh-copy-id or do it mannaully example of options:
./dracut -l -H -a ssh-client --sshkey /root/.ssh/id_rsa i.img
2. interactive mode:
need use --ctty option, ie.:
./dracut -l -H -a ssh-client --ctty i.img

---
 dracut                                 |    3 +-
 dracut.8.xml                           |    8 ++++
 modules.d/95ssh-client/module-setup.sh |   61 ++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+), 1 deletions(-)
 create mode 100644 modules.d/95ssh-client/module-setup.sh
dracut +2 -1
index 24a89e6..c10c0bb 100755
@@ -233,6 +233,7 @@ while (($# > 0)); do
         --debug)       debug="yes";;
         --profile)     profile="yes";;
         --ctty)        cttyhack="yes";;
+        --sshkey)      read_arg sshkey   "$@" || shift;;
         -v|--verbose)  ((verbosity_mod_l++));;
         -q|--quiet)    ((verbosity_mod_l--));;
         -l|--local)    allowlocal="yes" ;;
@@ -590,7 +591,7 @@ export initdir dracutbasedir dracutmodules drivers \
     add_drivers mdadmconf lvmconf filesystems \
     use_fstab libdir usrlibdir fscks nofscks cttyhack \
     stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
-    debug host_fs_types host_devs
+    debug host_fs_types host_devs sshkey
 
 # Create some directory structure first
 [[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}"
dracut.8.xml +8 -0
index a46fc04..a88fe16 100644
@@ -370,6 +370,14 @@ Default:
         </varlistentry>
         <varlistentry>
           <term>
+            <option>--sshkey&nbsp;<replaceable>&lt;sshkey file&gt;</replaceable></option>
+          </term>
+          <listitem>
+            <para>ssh key file used with ssh-client module.</para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>
             <option>-l</option>
           </term>
           <term>
modules.d/95ssh-client/module-setup.sh new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
1.7.1

A message that is not in the archive (sent off-list or not yet received): 20111223080430.GA12670-4/[email protected]

#2 lore raw
Quoted 7 lines · Dave Young

with --sshkey option you can provide the ssh key to be installed

Usage:
1. sshkey mode:
transfer your public key to remote machine with ssh-copy-id or do it mannaully example of options:
./dracut -l -H -a ssh-client --sshkey /root/.ssh/id_rsa i.img

...

Quoted 3 lines

+    # Copy over ssh key and knowhosts if needed
+    [[ $sshkey ]] && {
+        inst $sshkey

This means value for sshkey option must include /root/.ssh/ otherwise it won't end up in the correct place inside initramfs?

A message that is not in the archive (sent off-list or not yet received): CAGi==UVyoOjY3vFJ2RbCmYZOkdfQMFYXAr_5JXEeb45i9wQTHg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

author
#4 lore raw
Quoted 8 lines · Alan Pevec
Quoted 7 lines · Dave Young

with --sshkey option you can provide the ssh key to be installed

Usage:
1. sshkey mode:
transfer your public key to remote machine with ssh-copy-id or do it mannaully example of options:
./dracut -l -H -a ssh-client --sshkey /root/.ssh/id_rsa i.img

Quoted 7 lines

...

modules.d/95ssh-client/module-setup.sh line 44

Quoted 3 lines
modules.d/95ssh-client/module-setup.sh new file +3 -0
+    # Copy over ssh key and knowhosts if needed
+    [[ $sshkey ]] && {
+        inst $sshkey

This means value for sshkey option must include /root/.ssh/ otherwise it won't end up in the correct place inside initramfs?

Thanks for your comment. Yes sshkey will be installed to same location as the param specified, For kdump we will use an option SSH_KEY_LOCATION which is defined in kdump.conf, by default it is /root/.ssh/kdump_id_rsa. In initrd we will use ssh -i SSH_KEY_LOCATION to connect to remote machine

Signature · 2 lines
Thanks
Dave
#5 lore raw
In reply to Dave Young
Quoted 11 lines · Dave Young

Add ssh-client module, which support ssh key mode and interactive mode. with --sshkey option you can provide the ssh key to be installed

Usage:
1. sshkey mode:
transfer your public key to remote machine with ssh-copy-id or do it mannaully example of options:
./dracut -l -H -a ssh-client --sshkey /root/.ssh/id_rsa i.img
2. interactive mode:
need use --ctty option, ie.:
./dracut -l -H -a ssh-client --ctty i.img

Seems --sshkey and --ctty are only for ssh-client module, so, what if the user specifies -sshkey or --ctty but doesn't use ssh-client module?

#6 lore raw
Quoted 13 lines · Cong Wang
Quoted 11 lines · Dave Young

Add ssh-client module, which support ssh key mode and interactive mode. with --sshkey option you can provide the ssh key to be installed

Usage:
1. sshkey mode:
transfer your public key to remote machine with ssh-copy-id or do it mannaully example of options:
./dracut -l -H -a ssh-client --sshkey /root/.ssh/id_rsa i.img
2. interactive mode:
need use --ctty option, ie.:
./dracut -l -H -a ssh-client --ctty i.img

Quoted 3 lines

Seems --sshkey and --ctty are only for ssh-client module, so, what if the user specifies -sshkey or --ctty but doesn't use ssh-client module?

For the record - ctty part was meant as a general feature - tty with control is pretty useful thing to have - and pretty trivial to add, so why not.

Though the patches I made earlier also included a few other things, dunno what's the state of them (probably none ;) ). HEAD differs significantly by now, so maybe I should redo them as v2.

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#8 lore raw
Quoted 19 lines · Michal Soltys
Quoted 14 lines · Cong Wang
Quoted 12 lines · Dave Young

Add ssh-client module, which support ssh key mode and interactive mode. with --sshkey option you can provide the ssh key to be installed

Usage:
1. sshkey mode:
transfer your public key to remote machine with ssh-copy-id or do it
mannaully
example of options:
./dracut -l -H -a ssh-client --sshkey /root/.ssh/id_rsa i.img
2. interactive mode:
need use --ctty option, ie.:
./dracut -l -H -a ssh-client --ctty i.img

Quoted 3 lines

Seems --sshkey and --ctty are only for ssh-client module, so, what if the user specifies -sshkey or --ctty but doesn't use ssh-client module?

Quoted 7 lines

For the record - ctty part was meant as a general feature - tty with control is pretty useful thing to have - and pretty trivial to add, so why not.

Though the patches I made earlier also included a few other things, dunno what's the state of them (probably none ;) ). HEAD differs significantly by now, so maybe I should redo them as v2.

Michal, my ssh module is based on usrmove branch of below:
git clone -b usrmove git://git.surfsite.org/pub/git/dracut.git

This branch is intend for some work of generic --mount option which can benefit /usr mount and kdump target mount

So maybe this branch is different with HEAD as well, how about just keep your patch align with usrmove branch?

Quoted 6 lines
Signature · 4 lines
-- 
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Thanks
Dave
#9 lore raw
In reply to a message not in the archive
Quoted 8 lines · Michal Soltys

For the record - ctty part was meant as a general feature - tty with control is pretty useful thing to have - and pretty trivial to add, so why not.

Though the patches I made earlier also included a few other things, dunno what's the state of them (probably none ;) ). HEAD differs significantly by now, so maybe I should redo them as v2.

Thanks for teaching this.

As ssh-module needs --ctty, it is good to let Dave send them as a whole patchset,
of course, you are still the author of that patch. :)

author
#10 lore raw
In reply to Cong Wang
Quoted 13 lines · Cong Wang
Quoted 11 lines · Dave Young

Add ssh-client module, which support ssh key mode and interactive mode. with --sshkey option you can provide the ssh key to be installed

Usage:
1. sshkey mode:
transfer your public key to remote machine with ssh-copy-id or do it mannaully example of options:
./dracut -l -H -a ssh-client --sshkey /root/.ssh/id_rsa i.img
2. interactive mode:
need use --ctty option, ie.:
./dracut -l -H -a ssh-client --ctty i.img

Quoted 3 lines

Seems --sshkey and --ctty are only for ssh-client module, so, what if the user specifies -sshkey or --ctty but doesn't use ssh-client module?

Thanks for review.
--sshkey is for ssh module only, I have added param info in doc. --ctty is not only for ssh, it can be used by other stuff. if use use --sshkey but do not add ssh-client module it will just have one more global variable sshkey, it will not add more file to initrd.

As for the param, the ideal way is create generic way to add dracut module param like something below:
./dracut -a ssh-client,sshkey=xyz

Another way is use kernel param like rd.sshkey=xyz, but I do not like this way.

So currently generic module param will need more effort also will influence all dracut modules, I think just add --sshkey is acceptable.

Quoted 6 lines

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Thanks
Dave

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#12 lore raw
Quoted 26 lines · Dave Young
Quoted 13 lines · Cong Wang
Quoted 11 lines · Dave Young

Add ssh-client module, which support ssh key mode and interactive mode. with --sshkey option you can provide the ssh key to be installed

Usage:
1. sshkey mode:
transfer your public key to remote machine with ssh-copy-id or do it mannaully example of options:
./dracut -l -H -a ssh-client --sshkey /root/.ssh/id_rsa i.img
2. interactive mode:
need use --ctty option, ie.:
./dracut -l -H -a ssh-client --ctty i.img

Quoted 3 lines

Seems --sshkey and --ctty are only for ssh-client module, so, what if the user specifies -sshkey or --ctty but doesn't use ssh-client module?

Thanks for review.
--sshkey is for ssh module only, I have added param info in doc. --ctty is not only for ssh, it can be used by other stuff. if use use --sshkey but do not add ssh-client module it will just have one more global variable sshkey, it will not add more file to initrd.

Quoted 6 lines

As for the param, the ideal way is create generic way to add dracut module param like something below:
./dracut -a ssh-client,sshkey=xyz

Another way is use kernel param like rd.sshkey=xyz, but I do not like this way.

Oops, kernel param is only usefull for runtime option of initrd, ignore above line.

Quoted 13 lines

So currently generic module param will need more effort also will influence all dracut modules, I think just add --sshkey is acceptable.

Quoted 6 lines

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Thanks
Dave
#13 lore raw
In reply to a message not in the archive
Quoted 20 lines · Dave Young
Quoted 13 lines · Cong Wang
Quoted 11 lines · Dave Young

Add ssh-client module, which support ssh key mode and interactive mode. with --sshkey option you can provide the ssh key to be installed

Usage:
1. sshkey mode:
transfer your public key to remote machine with ssh-copy-id or do it mannaully example of options:
./dracut -l -H -a ssh-client --sshkey /root/.ssh/id_rsa i.img
2. interactive mode:
need use --ctty option, ie.:
./dracut -l -H -a ssh-client --ctty i.img

Quoted 3 lines

Seems --sshkey and --ctty are only for ssh-client module, so, what if the user specifies -sshkey or --ctty but doesn't use ssh-client module?

Quoted 5 lines

Thanks for review.
--sshkey is for ssh module only, I have added param info in doc. --ctty is not only for ssh, it can be used by other stuff. if use use --sshkey but do not add ssh-client module it will just have one more global variable sshkey, it will not add more file to initrd.

I am not objecting --sshkey, I am suggesting to print something to say --sshkey has no effect when ssh-client module is not included.

Quoted 5 lines

As for the param, the ideal way is create generic way to add dracut module param like something below:
./dracut -a ssh-client,sshkey=xyz

True, dracut does lack some way to pass a module specific parameter from command line...

A message that is not in the archive (sent off-list or not yet received): CAM_iQpVonkSXUDhVyrFiqam2Rgtogzt=FYSn1-q8h1uE6BTvPw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

author
#15 lore raw
Quoted 21 lines · Cong Wang
Quoted 20 lines · Dave Young
Quoted 16 lines · Cong Wang
Quoted 11 lines · Dave Young

Add ssh-client module, which support ssh key mode and interactive mode. with --sshkey option you can provide the ssh key to be installed

Usage:
1. sshkey mode:
transfer your public key to remote machine with ssh-copy-id or do it mannaully example of options:
./dracut -l -H -a ssh-client --sshkey /root/.ssh/id_rsa i.img
2. interactive mode:
need use --ctty option, ie.:
./dracut -l -H -a ssh-client --ctty i.img

Seems --sshkey and --ctty are only for ssh-client module, so, what if the user specifies -sshkey or --ctty but doesn't use ssh-client module?

Quoted 8 lines
Quoted 5 lines

Thanks for review.
--sshkey is for ssh module only, I have added param info in doc. --ctty is not only for ssh, it can be used by other stuff. if use use --sshkey but do not add ssh-client module it will just have one more global variable sshkey, it will not add more file to initrd.

I am not objecting --sshkey, I am suggesting to print something to say --sshkey has no effect when ssh-client module is not included.

yes, print some info is better, will do

Quoted 9 lines
Quoted 6 lines

As for the param, the ideal way is create generic way to add dracut module param like something below:
./dracut -a ssh-client,sshkey=xyz

True, dracut does lack some way to pass a module specific parameter from command line...

Signature · 2 lines
Thanks
Dave