Generating default SSH hostkey failed when installing confd-6.4.3. How to resolve it? Thanks a lot!

[zhaohongji@129-234 confd-6.4.3]$ sh confd-6.4.3.linux.x86_64.installer.bin my_install_dir
INFO Unpacked confd-6.4.3 in /home/zhaohongji/Desktop/confd-6.4.3/my_install_dir
INFO Found and unpacked corresponding DOCUMENTATION_PACKAGE
INFO Found and unpacked corresponding EXAMPLE_PACKAGE
INFO Generating default SSH hostkey (this may take some time)
open /home/zhaohongji/Desktop/confd-6.4.3/my_install_dir/etc/confd/ssh/ssh_host_rsa_key failed: Permission denied.
INFO SSH hostkey generated
INFO Environment set-up generated in /home/zhaohongji/Desktop/confd-6.4.3/my_install_dir/confdrc
INFO ConfD installation script finished

Hello,

not sure what is wrong. Looks like some file permission issue. I have tried following:

$ ./confd-6.4.3.linux.x86_64.installer.bin /tmp/my_install-dir
INFO  Unpacked confd-6.4.3 in /tmp/my_install-dir
INFO  Found and unpacked corresponding DOCUMENTATION_PACKAGE
INFO  Found and unpacked corresponding EXAMPLE_PACKAGE
INFO  Generating default SSH hostkey (this may take some time)
INFO  SSH hostkey generated
INFO  Environment set-up generated in /tmp/my_install-dir/confdrc
INFO  ConfD installation script finished

Please, can you try

./confd-6.4.3.linux.x86_64.installer.bin /tmp/my_install-dir in your environment if it fails as well?

You may also try (takes some time)

strace -f ./confd-6.4.3.linux.x86_64.installer.bin /tmp/my_install-dir &> out_strace.log

and analyze out_strace.log - around text SSH hostkey generated

I have:

[pid 23232] getpid()                    = 23232
[pid 23232] getpid()                    = 23232
[pid 23232] getpid()                    = 23232
[pid 23232] getpid()                    = 23232
[pid 23232] stat("/tmp/my_install-dir/etc/confd/ssh/ssh_host_rsa_key", 0x7ffeb0d08c70) = -1 ENOENT (No such file or directory)
[pid 23232] openat(AT_FDCWD, "/tmp/my_install-dir/etc/confd/ssh/ssh_host_rsa_key", O_WRONLY|O_CREAT|O_TRUNC, 0600) = 3
[pid 23232] write(3, "-----BEGIN RSA PRIVATE KEY-----\n"..., 1679) = 1679
[pid 23232] close(3)                    = 0
[pid 23232] openat(AT_FDCWD, "/tmp/my_install-dir/etc/confd/ssh/ssh_host_rsa_key.pub", O_WRONLY|O_CREAT|O_TRUNC, 0644) = 3
[pid 23232] fcntl(3, F_GETFL)           = 0x8001 (flags O_WRONLY|O_LARGEFILE)
[pid 23232] fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
[pid 23232] write(3, "ssh-rsa AAAAB3NzaC1yc2EAAAADAQAB"..., 400) = 400
[pid 23232] close(3)                    = 0
[pid 23232] write(1, "Generating public/private rsa ke"..., 564) = 564
[pid 23232] exit_group(0)               = ?
[pid 23232] +++ exited with 0 +++
<... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 23232
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=23232, si_uid=1000, si_status=0, si_utime=6, si_stime=0} ---
rt_sigreturn({mask=[]})                 = 23232
dup2(11, 1)                             = 1
close(11)                               = 0
write(1, "INFO  SSH hostkey generated\n", 28INFO  SSH hostkey generated
) = 28
pipe([3, 4])                            = 0

thank you for your replying.

I have tried the following command, it still failed.

[zhaohongji@129-234 confd-6.4.3]$ strace -f -o output.txt ./confd-6.4.3.linux.x86_64.installer.bin /tmp/my_install-dir 
INFO  Unpacked confd-6.4.3 in /tmp/my_install-dir
INFO  Found and unpacked corresponding DOCUMENTATION_PACKAGE
INFO  Found and unpacked corresponding EXAMPLE_PACKAGE
INFO  Generating default SSH hostkey (this may take some time)
**open /tmp/my_install-dir/etc/confd/ssh/ssh_host_rsa_key failed: Permission denied.**
INFO  SSH hostkey generated
INFO  Environment set-up generated in /tmp/my_install-dir/confdrc
INFO  ConfD installation script finished

and in the output.txt, it includes the following info.

4192  stat("/tmp/my_install-dir/etc/confd/ssh/ssh_host_rsa_key", 0x7fffd51c45d0) = -1 EACCES (Permission denied)
4192  open("/tmp/my_install-dir/etc/confd/ssh/ssh_host_rsa_key", O_WRONLY|O_CREAT|O_TRUNC, 0600) = -1 EACCES (Permission denied)

I don’t know why? The folder has 777 mode.
[zhaohongji@129-234 /tmp]$ chmod 777 my_install-dir/
[zhaohongji@129-234 /tmp]$ ll
total 84

drwxrwxrwx. 2 zhaohongji zhaohongji  4096 Feb  4 19:09 my_install-dir

Maybe the redhat has no privilege to access /tmp/my_install-dir/etc/confd/ssh/ssh_host_rsa_key
But when I execute “cat /tmp/my_install-dir/etc/confd/ssh/ssh_host_rsa_key” in the cli, it shows right.

[zhaohongji@129-234 confd-6.4.3]$ cat /tmp/my_install-dir/etc/confd/ssh/ssh_host_rsa_key
cat: /tmp/my_install-dir/etc/confd/ssh/ssh_host_rsa_key: No such file or directory

It is so strange !

Obviously write access to the ‘ssh’ directory is needed when creating the key file - but that shouldn’t be a problem since the directory was created by the installer. Anyway, the installer just invokes your OS’ ‘ssh-keygen’ command to generate the key - i.e. in your case it will be run as
ssh-keygen -t rsa -f /tmp/my_install-dir/etc/confd/ssh/ssh_host_rsa_key -N ''
If that doesn’t work, it is not a problem with the installer…

Hm, there should be an empty string ‘’ after the -N option - for some reason it doesn’t show up in the text above.

Thank you for your reply.
I have tried your commands, but it still failed.

[zhaohongji@129-234 my_install-dir]$ ssh-keygen -t rsa -f /tmp/my_install-dir/etc/confd/ssh/ssh_host_rsa_key -N ''
Generating public/private rsa key pair.
open /tmp/my_install-dir/etc/confd/ssh/ssh_host_rsa_key failed: Permission denied.
Saving the key failed: /tmp/my_install-dir/etc/confd/ssh/ssh_host_rsa_key.
[zhaohongji@129-234 my_install-dir]$ 

Does it mean that something is wrong with my Redhat Linux? Thanks!