Code Monkey home page Code Monkey logo

kasini3000's Introduction

kasini3000

This is an open source, free, cross-platform, batch, automation, operation and maintenance tool.

Similar to Puppet, SaltStack, Ansible, pipeline. Specifically developed for the shortcomings of ansible.

Cross-platform means that the master computer can be win or linux.

The master connected to the linux node uses the ssh protocol. The master connected to the win node uses the winrm protocol.

Master Control node based on [open source + free + cross-platform] powershell language.Instead of being based on YAML like Ansible.

The master computer uses the "push" script, push script blocks, and push and pull files to node. You can transfer PS1 script files, code blocks, and object level variables between the master and the node. loading DLL files by .Net language.

There are no agent on the Linux node, so there are no security issues. After open-sshd authentication, sshd will execute powershell. This is similar to ansible.

For the Linux version master, you can use both Kasini3000 and Ansible. You can use powershell object variables to help store ansible return values.

Some PS1 scripts can be used independently. This means that some features do not require powershell installation on Linux. These scripts are used to manage vmware esxi, switches, unix, terminals, IoT, and other SSH port node. It also supports bulk telnet.

Bash can be invoked through powershell,

100% compatible with .bash scripts on linux;

100% compatible with .csh scripts;

100% compatible with .zsh scripts, .py, .perl, etc.

100% compatible with .bat scripts on win; vbs scripts, py, etc.

Any old linux script can be executed from the master to the node by [the source code is embedded in the ps1 script file of the master], or the file is distributed.


架构

Project name: "kaiiit's Hotel" (tentative name)

Project name alias: "ps1 Dragon Long knife"

Project name development : kasini3000

Code main site: https://gitee.com/chuanjiao10/kasini3000 中文

code mirror: https://github.com/kasini3000/kasini3000

The slogan of "kaisini3000" is:

"[the Keyboard Space Monster] on .yaml file let you cried.Don't learn yaml keywords, and many modules. kasini3000 to make win, linux, command line great again"

status: Move to github, English translation. little by little.

卡死你3000

Set Language to english [set_Language_english.ps1]

download:

win master:

Remove-Item -LiteralPath 'c:\ProgramData\kasini3000' -Recurse -Force -Confirm:$false
cd  'c:\ProgramData\'
git.exe clone https://gitee.com/chuanjiao10/kasini3000.git
#or git.exe clone [email protected]:chuanjiao10/kasini3000.git

linux master:

rm -rf /etc/kasini3000
export LANG=zh_CN.UTF-8
cd /etc
git clone https://gitee.com/chuanjiao10/kasini3000.git
#or git clone [email protected]:chuanjiao10/kasini3000.git

data moved from 3.1 alpha 1 :

win: from 【c:\ProgramData\kasini3000】 to 【~\Documents\kasini3000】 linux: from 【/etc/kasini3000】 to 【/root/kasini3000】

only move data


NEWS

Version history and release note:

https://gitee.com/chuanjiao10/kasini3000/wikis/news?sort_id=1740996


Feedback (Support Chinese and English):

Technical support ---> Tencent qq group, chargeable. Please provide detailed questions, source code, and screenshots. Thank you.

qq international english pc: https://dldir1.qq.com/qqfile/QQIntl/QQi_PC/QQIntl2.11.exe

Dedication code ---> Go to gitee.com to submit the code.

Submit a bug ---> Go to issues in gitee.com and submit a bug.

Submit new functional requirements ---> Go to issues in gitee.com and submit new functional requirements.

Submit LABEL

  • bug

  • 问题 or Question

  • 新需求 or Enhancement

  • 翻译成英文 or Translation into English demand

Submit Template:

  • mast open verbose by 【c:\ProgramData\kasini3000\v-kai开启详细信息输出.ps1】

  • Steps to reproduce

  • Expected behavior

  • Actual behavior

Environment data

  • master os version.powershell version on master.

  • node os version.powershell version on node.


function

edit node table of ip,port,user,pwd on master.

copy [this project/docs/examples/nodelist.csv]

to win: c:\Users\【your_name】\Documents\kasini3000\nodelist.csv

to linux: /root/kasini3000/nodelist.csv

for linux node:

1 Create ssh-key-file on master.

2 Manual push ssh-key-file to node.

see manual https://gitee.com/chuanjiao10/kasini3000/wikis/安装linux版卡死你3000主控机?sort_id=2655465

NOTE:

all command manual in this file [/docs/kasini3000_manual.xlsx]

1 krun.ps1

When the script transfers variable parameters remotely, the object can be directly transferred.

This function is the only one in the world! A generation stronger than other batch operation and maintenance tools!

cdip 1.2.3.4 #nodeip
$object_result_returned_from_the_node_instead_of_string = krun.ps1 { command on node} -allparameter $master_local_object_1,$master_local_object_2

2 Cross-platform cmdb and disk task queue based on sqlite implementation.

3 Multi-process concurrent tasks.

cdg group1
k-commit.ps1 -file d:\script_onmaster.ps1 -allparameter $master_local_object_1,$master_local_object_2

4 Multi-threaded concurrent tasks.

cdg group1
k-commit-rs.ps1 -file d:\script_onmaster.ps1 -allparameter $master_local_object_1,$master_local_object_2

5 Timed tasks. Supports triggers that cycle every 67 minutes.

Can be set based on multi-threading or multi-process

Script example https://gitee.com/chuanjiao10/kasini3000/wikis/卡死你3000脚本例子

5.1 Active and standby high availability function, the first version of alphi. It is based on the heartbeat. The usage scenarios are:

1 kasini3000 master computer (main=yingzheng) running a timed task, it will push [timed task database] to (standby) every 10 seconds.

2 When the master is hung up, (standby = Yingfusu) the master computer will detect the heartbeat and start timing tasks.

3 After the main recovery, the standby will close the timed task and return the [timed task database], and the main will continue the timed task.

6 File copy: win<--->win, win<--->linux, linux<--->linux. Support mac. raspberry pie.

cdip 1.2.3.4 #nodeip
kct -path d:\abc -Destination /tmp #copy files from master to node.
kcf -path /tmp2 -Destination d:\123 -Recurse #copy files from node to master.

Support cross-regional and cross-public cloud vendors. Manage the public cloud, private cloud, and controlled machine at the same time.

Supports the management of vmware vcenter and vmhost host computers based on powercli on win and linux kasini3000 main master machine. Provide the cdESXi.ps1 command.

windows master (32-bit os is not supported):

win8.1, win10, win11, win2012r2, win2016, win2019, win2022

linux master (32-bit os is not supported):

centos7, centos8, ubuntu1804, ubuntu2004, ubuntu2204, debian10, debian11, alpine3.8--- 3.11. Centos6 is not supported

linux master computer supports these cpu architectures: x64, arm.

Linux master restriction: cannot manage win node

both windows master and linux master

copy [nodelist.csv] between windows master and linux master

copy folder [c:\Users\【your_name】\Documents\kasini3000\cmdb] between [/root/kasini3000/cmdb/] for Backstage job.

script both on win node and linux node:

jc检测【win-linux进程命令行中】关键字的并发数z3.ps1 # Returns the number of command line keywords, or pid array

hq获取cpu空闲_当前实时值_win_linux通用3.ps1 # get cpu free for all cpu-core eg: 0.95

hqm获取空闲内存MB_当前实时值_win_linux通用1.ps1 # get free mem by MB

hqpm根据进程pid_获取进程占用的物理内存_win_linux通用.ps1 # get process memory by pid

hqpm根据端口_获取进程pid_win_linux通用.ps1 # get pid by open port

win node:need enable winrm

  • Win node machine supports these versions(32-bit os is supported): win8.1, win10, win2012r2, win2016, win1019, win7 (need to install ps5.1), win2008r2 (need to install ps5.1)

  • Automatic/Manual Change 16-bit random number password for ALL win nodes in batches,then write new pwd to [nodelist.csv] on master pc.

That is [Regularly automatically update the password of the node machine].

  • The master computer controls the node computer, without windows domain. That is, whether there is a windows domain can be controlled.

  • When the master machine=win and the node machine=win, powershell-dsc is 100% supported. At the same time 100% support the Linux version of powershell-dsc

linux node:

Linux node computers support these distributions(32-bit os is supported):

centos7, centos8, ubuntu1604, ubuntu1804, ubuntu2004, ubuntu2204, debian9, debian10, debian11, alpine3.8---3.11, Raspberry Pi linux, Raspberry Pi win10-iot. Centos6 is not supported

Use dual ssh-key-file to manage Linux node computers. You can alternately change ssh-key-file for linux root. (equivalent to two passwords for the root account) automatically update ssh pub keys on node when run command.

bkj_install_linuxpackage.ps1 encapsulates yum and apt-get and apk add. Install [same name] software packages across Linux distributions:

cdg  group1
k-commit -scriptblock { bkj_install_linuxpackage.ps1 'wget','bash' } # The package name is different between the rows and versions, you can also put it here

bkj_remove_linuxpackage.ps1

on windows master

  • Chinese and English voice alarm function. You need to install a sound card and speakers on the master computer. (Does not support linux master)
baoj中英文声音报警.ps1 '报告司令,卡死你3000,工作正常!happy,new,year,2020'
  • Change Windows Terminal Background Image. Support gif animation.

效果图

You can store the memory map in the relevant directory yourself!

Its main function is:

when a script or command error occurs, wrtie-error, at the same time, it calls related scripts and changes the Windows Terminal background image to achieve the purpose of eye-catching reminders.

  • playing wav, mp3, and video.

  • windows gui to view returned result (in sqlite database)


features

ps1 script advantage:

  • Pipe symbol transfer object:
'abc' | foreach-object { $_.toupper() }
  • remote transfer object:
$file_objects_returned_from_remote = krun -scriptblock {get-childitem /tmp}
$file_objects_returned_from_remote | foreach-object { $_.LastWriteTime }
  • Global public variable object for two script:
$global:abc = 1
  • unicode strings for cjk script, and BOM head for .ps1

  • Script parameters: simple to use, more powerful than shell

  • .ps1 vs .yaml vs .sh :No spaces, indentation issues

  • Use vscode+remote ssh for remote debugging. Such as single step, breakpoint, execute a script selected by the mouse. The debugging efficiency is 10 times that of yaml and shell.

  • has for,foreach.no need JINJIA2

  • All codes are written into a single script and no need transfer script file. You can from node1 ---> node2 ---> node3. This is useful for penetrating bastion machines and managing hardware from a specific server.

  • Write 3 layers of loops, such as foreach set while, plus exit condition judgment. Yaml is laborious to express, especially when using rules.

  • in script:a call b then call c easy than yaml.

  • The arm32 version of powershell supports Android phones, Android tablets, and Apple OSX.

Windows, linux, operation consistency.

Any user who uses "yaml keyword definition" must strictly abide by [the other party's yaml definition]. and yaml has issues with spaces and indentation. Referred to as [user is a slave]. And any use "script-based code" [user is the master].

SaltStack has an agent. This agent has a remote command execution vulnerability in May 2020. See cve-2020-11651 cve-2020-11652 for details. kasini3000 and aisible will never have similar loopholes! In kasini3000 and Ansible, the agents that open ports to monitor are: open-sshd of linux and winrm of win.

Ansible and Tencent Cloud Blue Whale do not support win master installation. When the controlled machine is win, the ps1 script does not need to be converted by yaml.

windows master: has gui app to show result. can use pic text2voice ,alarm with sound.

call from jenkins,zabbix easy.

Q: Why is kasini3000 number one in the world?

A:

  • Control the invincible hand of the windows node.

  • Control linux node 100% compatible with shell script.

  • Remote delivery of objects.


document

excel manual

/docs/kasini3000_manual.xlsx

download:

git clone https://gitee.com/chuanjiao10/kasini3000.git

git clone [email protected]:chuanjiao10/kasini3000.git

install kaiiit's Hotel

linux master: https://gitee.com/chuanjiao10/kasini3000/wikis/安装linux版卡死你3000主控机

win master: https://gitee.com/chuanjiao10/kasini3000/wikis/安装win版卡死你3000主控机

linux node: https://gitee.com/chuanjiao10/kasini3000/wikis/安装linux版卡死你3000被控机?sort_id=2951718

win node: https://gitee.com/chuanjiao10/kasini3000/wikis/安装win版卡死你3000被控机?sort_id=2951719

one key install powershell agent for linux node. One-click install powershell agent for linux node.

https://gitee.com/chuanjiao10/kasini3000_agent_linux

tech:

https://www.cnblogs.com/piapia/p/16534765.html

Q&A

https://gitee.com/chuanjiao10/kasini3000/wikis/卡死你3000脚本编写要求和常见问题

Script example

https://gitee.com/chuanjiao10/kasini3000/wikis/卡死你3000脚本例子

jenkins example

https://gitee.com/chuanjiao10/kasini3000/wikis/卡死你3000的jenkins例子

Use [self-built CA] and [self-built certificate] for winrm 《Four levels of winrm security》

https://www.cnblogs.com/piapia/p/11897713.html

Change Windows Terminal Background Image /docs/Change Windows Terminal Background Image readme.md


roadmap

  • 2020-04---2021-08, this project will be Englishized. Script name: Add English alias. Script parameter name: add English alias. Added English version of error message. Increase the English version of the manual.

  • 2020-06--2022-06, welcome to cooperate with this project. Add web ui.

  • Graphical interface monitoring. It will only develop features that are not available in Zabbix, Prometheus. (This feature is delayed in development, delayed in launch)

  • Added support for asynchronous callback tasks.


License is customize

licenses\LICENSE.TXT


Disclaimer

Users should do their own tests before using them.

The consequences are not responsible!

Do not save your files in kasini3000 folder, kasini3000 will delete your files when bg update or sync by git.

kasini3000 will overwrite your old ssh pub key file on linux node. ---> /root/.ssh/authorized_keys .The old pub key will invalid.

The node machine account password is stored in plain text on the master machine.

The user should ensure the security on the master machine by himself.

Once the master machine is controlled by the hacker, all the node machines will be controlled by the hacker.

kasini3000's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

kasini3000's Issues

Suggestion - Use Docker part two

The responsibility and management of the SSH keys is left to the user, options include, but are not limited to

  • Mount the keys directly in a docker volume
  • Mount a host system directory directly as a volume for the keys
  • Load the password protected private key from an external source and unpack within container
  • Use a wrapping key on the private key file from external source and unwrap within container
  • Use secure cloud service to provide keys, for example Azure Vault or AWS KMS
  • Use ssh-agent to manage the keys
  • Hardware device such as YubiKey

Copy of Git included in repository

Why is there a full copy of git in the repository when in order to install the code you already needed git installed to do the installation?

Suggestion - simplification of /etc/os-release matching

There are 117 places in the scripts where /etc/*-release is attempted to be matched to determine the capabilities of the host operating system.

The code could be greatly simplified by parsing ID and ID_LIKE just once and using those field values to determine host capability

Example code

$global:ID = [string]$null
$global:ID_LIKE = @()

foreach($line in [System.IO.File]::ReadLines("/etc/os-release"))
{
	$nameValue = $line.Split("=")
	if ( $nameValue.Length -gt 1)
	{
		switch ( $nameValue[0] )
		{
			"ID" { $global:ID = $nameValue[1].Trim().Trim('"') }
			"ID_LIKE" { $global:ID_LIKE = $nameValue[1].Trim().Trim('"').Split(" ") }
		} 		
	}
}

Write-Output ( "ID=" + $global:ID )

Write-Output ( "ID_LIKE=" + $global:ID_LIKE )

On AlmaLinux this then prints

ID=almalinux
ID_LIKE=rhel centos fedora

Then to determine if the system uses "deb" packages see if ID is "debian" or ID_LIKE contains "debian"

Likewise to determine if system uses "rpm" check for ID is "fedora" or "mariner" or ID_LIKE contains "fedora"

This would greatly simplify the code in those cases.

Suggestion - RPM and Debian packaging for Linux users

I have built a proof of concept to build rpm and deb packages for kasini3000

This is the professional way to distribute software for Linux

This installs the content in /usr/share/kasini3000 and a symbolic link in /etc/kasini3000

Advantages over the ZIP file approach are

  • File is only 20MB rather than over 200MB
  • You only install the binary files you need, not what other people need
  • You can let the platform sort out dependencies to rely on other packages, for example powershell
  • SQL interop dll is already set to the correct version for the platform
  • /usr/lib/systemd/system/kasini3000.service installed directly

[ ] The server is required, which requires payment.

You can attach packages directly to releases on Github, exactly as PowerShell does. You can also host package repositories in Oracle Cloud with the Free Tier.

[ ] It is troublesome to import the gpg key.

It is completely standard procedure for Linux, it is well documented at docker debian, docker-rpm and microsoft

All you need is to provide either clear instructions or another package which contains both the GPG public key and the repository definition as appropriate for apt or yum.

[ ] Cannot update incrementally.

If you only package what is required then you only need to issue a new version when that content has changed. Under the control of apt and yum it will update versions in place.

Question - how do we tell what version of the project we are using

The README mentions "3.1 alpha 1"

How do we know what version we have installed or are available?

The repository at https://gitee.com/chuanjiao10/kasini3000 has no tags so we can't tell what version from the repository.

What is the intended release cycle? Is this intended to be a rolling release with no versions?

What is the process to ensure only good releases are used by "1incremental_update_kasini3000_from_git.ps1" on the client?

Suggest login to node should not use root account

In the LICENSE.TXT it says

kasini3000 will overwrite your old ssh pub key file on linux node. ---> /root/.ssh/authorized_keys .The old pub key will invalid.

The node machine account password is stored in plain text on the master machine.

It is not considered good practice to remote login as root. As an example, when you create a new virtual machine in AWS or Oracle Cloud you get SSH with a non-root user who can then use sudo to execute administration commands.

I suggest that a similar approach is done with kasini3000 where it uses a non-root user to login and run scripts, then only use sudo for specific administration commands.

I would also suggest that once you have a public key in ~/.ssh/authorized_keys then kasini3000 no longer needs the password to the node. All access would be secure and authenticated by SSH.

Suggestion - Kasini3000 in a Docker container

This is a proof of concept. The idea is to address two issues

  • The size of the Git repository versus what is required at runtime on Linux
  • Running of the crontab script as root

The basic idea is to use the builder pattern in Docker, create an image that can run PowerShell and install the latest version of kasini3000 directly from git.

Within the builder, the redundant contents of /etc/kasini3000 are removed then a new image is created without the git tool installed.

When actually running the image you would use a docker volume to contain the CMDB and other contents of the data directory which would then be mounted at /root/kasini3000.

This means that Kasini3000 can run unchanged but if there are problems the docker container can be deleted, and then restarted from the image again.

The data will still be in the mounted volume.

In order to update the scripts, then the Docker image just needs to be built again getting fresh clone from the git repository.

Dockerfile

FROM mcr.microsoft.com/powershell:latest AS builder

RUN apt-get update && apt-get -y install git

RUN git clone --depth=1 https://gitee.com/chuanjiao10/kasini3000.git /etc/kasini3000

RUN rm -rf /etc/kasini3000/.git
RUN rm -rf /etc/kasini3000/master_script/kasini3000
RUN rm -rf /etc/kasini3000/lib/cwrsync
RUN rm /etc/kasini3000/lib/kasini3000/plink.exe
RUN rm /etc/kasini3000/lib/kasini3000/psftp.exe
RUN rm /etc/kasini3000/lib/kasini3000/ProgramFiles_WindowsPowerShell_Modules/WinSCP/5.17.10.0/bin/WinSCP.exe

FROM mcr.microsoft.com/powershell:latest

COPY --from=builder /etc/kasini3000 /etc/kasini3000

RUN mkdir /root/kasini3000 /root/.ssh && chmod go-rwx /root/.ssh

RUN ssh-keygen -t rsa -b 4096 -N '' -f /root/.ssh/id_rsa

CMD ["/bin/sh", "-e", "-c" , "while true; do /usr/bin/pwsh --file /etc/kasini3000/u_db_crontab.ps1; sleep 28; done"]

This is a proof of concept, you may want to generate the ssh keys outside of the docker and copy them in when building, or even keep them in another volume that is mounted at /root/.ssh. This proof does not show the setting up the Interop DLLs required for SQLlite.

Code is using sha1 for validation of authorized_keys

SHA1 is considered deprecated

52 occurrences of "sha1"

run_win2linux_key_pwd.ps1

$主控机公钥sha1 = Get-FileHash -Algorithm sha1 -LiteralPath "${global:kasini3000_data_path}\ssh_key_files_old1\authorized_keys"
$被控机公钥sha1 = Invoke-Command -Session $private:连接111 -ScriptBlock { Get-FileHash -Algorithm sha1 -LiteralPath '/root/.ssh/authorized_keys' }
Write-Verbose ("公钥: {0} '---' {1} " -f ${主控机公钥sha1}.Hash,${被控机公钥sha1}.Hash)
if ($主控机公钥sha1.Hash -ne $被控机公钥sha1.Hash)

Project page says it supports Raspberry Pi but install refers to amd64

Hi, project page says project supports Raspberry Pi.

When looking at zkj_install_powershell_从win主控机到linux被控机.ps1 it refers to amd64.

I see no references for either aarch64 or any 32 bit arm architectures.

What Raspberry Pi operating systems does it support?

Thanks.

Chain of custody is broken for SQLite interop dlls

It's easy to determine if it's the original program. Check the software signature on properties page of the right mouse button or go to the official website to compare the sha256 value.

The version of System.Data.SQLite.dll is 1.0.112.0.

This is not listed at https://www.sqlite.org/download.html or https://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki.

I finally tracked it down to https://system.data.sqlite.org/downloads/1.0.112.0/sqlite-netStandard20-binary-1.0.112.0.zip

unzip -l  sqlite-netStandard20-binary-1.0.112.0.zip
Archive:  sqlite-netStandard20-binary-1.0.112.0.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
   351744  2019-10-27 06:31   System.Data.SQLite.dll
    12492  2019-05-15 00:31   System.Data.SQLite.dll.config
   117056  2019-10-27 06:31   System.Data.SQLite.pdb
  1094797  2019-10-27 06:31   System.Data.SQLite.xml
---------                     -------
  1576089                     4 files

The files sizes match and so does the SHA256 for System.Data.SQLite.dll.

I was unable to find the interop dlls. The closest I could find was the NuGet package which is 1.0.103.0

https://www.nuget.org/packages/SQLite.Interop.dll/

The version included in the project is 1.0.111.0.

Where do the interop dlls come from? Thanks.

Are you willing to provide suggestions on [using kasini3000 in a separate alpine disk]?

For the security of the Linux host computer, I recommend using alpine linux for the following reasons:

  • Its software package is small and safe enough.
  • It takes up memory and has very little cpu.
  • The Kasini 3000 can use both the Windows host and the Linux host at the same time.
  • It is basically live cd, that is, linux started from iso. Just download the new iso version to complete the linux upgrade.
  • It supports installation to the hard disk. After installation, you can still start through the ios on the CD, which basically does not take up hard disk space.
  • You can store the/etc/kasini3000 directory on the hard disk and install the powershell on the hard disk.
  • Using kasini3000 in alpine linux is no different from the other linux distribution.

I have also tried microsoft cblm 2.0, which seems to be not well. The main reason is that after installation on the hard disk, it takes up a lot of disk space, which is no different from the ordinary Linux distribution.

Git unable to update itself in Windows using git

Steps to reproduce

  1. clone the repository with

git clone https://gitee.com/chuanjiao10/kasini3000.git kasini3000

  1. move into the repository and checkout 26e895d6cc47d75718c73525660c6e7c010737ec, this is when the repository was using git 2.35.1.2

  2. Now run the git.exe to update to current version of git in the repository

.\master_script\kasini3000\git\mingw64\bin\git.exe checkout master

Result is

Unlink of file 'master_script/kasini3000/git/mingw64/bin/git.exe' failed. Should I try again? (y/n) y
Unlink of file 'master_script/kasini3000/git/mingw64/bin/git.exe' failed. Should I try again? (y/n) y
Unlink of file 'master_script/kasini3000/git/mingw64/bin/git.exe' failed. Should I try again? (y/n) y
Unlink of file 'master_script/kasini3000/git/mingw64/bin/git.exe' failed. Should I try again? (y/n) n
error: unable to unlink old 'master_script/kasini3000/git/mingw64/bin/git.exe': Invalid argument
Updating files: 100% (1431/1431), done.
Previous HEAD position was 26e895d 更新:git库到2.35.1.2
Switched to branch 'master'
M       master_script/kasini3000/git/mingw64/bin/git.exe
Your branch is up to date with 'origin/master'.

End result is that git.exe is unable to update itself in the repository on Windows.

.\master_script\kasini3000\git\mingw64\bin\git.exe --version
git version 2.35.1.windows.2

In master, it should currently be

git version 2.35.3.windows.1

Formal package required for installation

Hi, interesting project and I like the cross platform support. I suggest don't install system from git, use a packaging mechanism to install exactly one version. On Linux I suggest /usr/share/kasini3000 would be a better location than /etc/kasini3000, the /etc location should only be for local configuration files. Use a DEB or RPM to install the required files on Linux. Likewise on Windows it would be better installed by MSI in c:\Program Files\kasini3000 with only local data files under c:\ProgramData\kasini3000. Using packages you can then update in place with new versions and use standard packaging mechanisms to know what is installed on any node. Data managed on Linux should be in say, /var/lib/kasini3000 rather that /etc/kasini3000.

Suggestion - please put tags on the git repository

Hi, you have a version history at https://gitee.com/chuanjiao10/kasini3000/wikis/news

But this is hard to match against the git repository using standard tools and for non Chinese readers.

Can you put git tags on the commits that match the formal releases? I recommend tags in plain ASCII with the simple release version.

This would make it easier for all users of your git repository to see the formal release history and allow tools to clone specific releases.

Cloning the whole repository, stepping through the git log and trying to parse kasini_version.ps1 is not very efficient.

It will make the git repository look well managed for a product with formal releases.

Thanks,

Suggest kasini3000.service uses onCalendar rather than RestartSec

You have a systemd service to invoke u_db_crontab.ps1

u_db_crontab.ps1 contains test for the the value of minutes before performing certain tasks.

You could use the onCalendar systemd timer mechanism in order to simply run scripts at scheduled times rather than programmatically trying to determine the time.

Likewise on Windows one can use scheduled tasks for the equivalent mechanism.

Suggestion - Package Kasini3000 as an MSI

Packaging Windows software as an MSI is the standard way to deliver software in managed environments.

It can be installed simply from Explorer or using msiexec. It can be easily removed using "Add and Remove Programs" and msiexec.

With well managed curation of the content in the MSI it can be under 20MB.

With a proper software release cycle you can produce an MSI for each version.

Visibility in "Add and Remove Programs" means the user is aware what is installed.

Suggest use hash-bang /usr/bin/env pwsh to assist Linux users

I notice that when following the installation instructions for Linux users, that none of the *.ps1 files have the execution bit set.

It is traditional, in a Linux environment, to simply be able to run scripts from the command line no matter what interpreter they use.

For PowerShell this means adding this as the first line..

#/usr/bin/env pwsh

This would be before the param block.

Then set the execution bit for the program using...

chmod +x xxxx.ps1

To update this in git use

git add --chmod=+x xxxx.ps1

So then for Linux users they don't have to prefix running a PowerShell script with "pwsh".

dpkg lock files are deleted

The purpose of the dpkg lock files is to protect the integrity of the package management system.

The sequence "rm -rf /var/lib/dpkg/lock;rm -rf /var/lib/dpkg/lock-frontend;" occurs in multiple places.

This is not good practice and risks corrupting the package management system and preventing normal operating system updates.

Putty Security in kasini3000

There are reports of Trojanized versions of PuTTY being distributed. These are versions of the original PuTTY but a backdoor has been added to the code.

For example: https://www.microsoft.com/security/blog/2022/09/29/zinc-weaponizing-open-source-software/

I notice that the git repository contains files such as psftp.exe and plink.exe which appear to be PuTTY programs.

How can we have confidence that the binary versions distributed by kasini3000 are not malicious versions?

Thank you for Code Review

Hi,

Thanks for the invite to kick the tyres of your project. It is certainly interesting and I wish you well with it.

You have made design choices along the way as any developer must do.

For me the two main roadblocks to using the project are the installation, mainly using git to install binary packages, and the use of root on Linux. But you are free to make your choices in your project.

Thanks again

kasini3000.service should run tasks as non-root user

As far as I can tell kasini3000.service is running u_db_crontab.ps1 as root.

It is best practice to run services as a non-root user and then only use sudo or set-uid in order to invoke limited functions that require root access.

A master node should not need to run anything as root on the master node while it is administering child nodes. The cases for running sudo should be limited to the single command required to perform the administration on the target system.

Running as non-root is best practice because it means that errors or misconfigurations in your application are much less likely to affect the rest of the system. It also provides less opportunity for your application to be inadvertently turned into a backdoor.

Postfix, apache, tomcat, systemd itself and many other well-behaved applications don't run the services as root.

While kasini3000 could be run within a docker container it would be without systemd, and if running as root within the docker it could still corrupt the files within the container due to misconfiguration or programming error.

Suggestion - compiling SQLite.Interop.dll ARM64 Linux

As far as I can tell, the SQLite.Interop.dll is the only native compiled component required for Kasini3000 ( apart from the correct PowerShell binaries being installed )

If you want to compile the matching SQLite.Interop.dll for ARM64 then you can get the 1.0.112.0 source from

https://system.data.sqlite.org/blobs/1.0.112.0/sqlite-netFx-source-1.0.112.0.zip

To build this on ARM64 Linux, unpack the zip in an empty directory and

cd Setup
bash ./compile-interop-assembly-release.sh

The result should be in

bin/2013/Release/bin/SQLite.Interop.dll

bkl_install_linuxpackage.ps1 and bkj_remove_linuxpackage.ps1 simplifications and improvements

Hi,

I had a look at bkj_install_linuxpackage.ps1 and bkj_remove_linuxpackage.ps1 and have some recommendations.

The identification of the platform would be improved by focusing on the ID and VERSION_ID fields in /etc/os-release rather than current pattern matching. Many of the patterns in the code don't match this record of existing /etc/os-release files.

There is a lot of code duplication between the two programs that I am sure could be shared.

It would also be simplified by identifying the package API type by operating system and using common routines rather than a function per operating system version.

There are question-marks around Amazon Linux in the code. ID="amzn" VERSION_ID="2" uses yum and rpm.

I don't know why there are "Start-Sleep" in the code or why you are trying to force delete the /var/lib/dpkg/lock* files. They are there for a reason and one should leave the operating system itself to manage its synchronisation and protection of the repository database files.

Some parts of the code use sudo, and other lines immediately next to them don't even though using a command that needs root access, eg the ubuntu cases in bkj_remove_linuxpackage.ps1

Apart from the exit 1 if the operating system is Windows, the scripts have exit 0 at the end. How does the caller know if they were successful?

Alpine bash is at /bin/bash

Normally the path for bash is /bin/bash just like /bin/sh

Can you not use normal PATH resolution for bash?

/usr/bin/bash: /etc/kasini3000/gx更新主控机ssh秘钥2z.ps1:129
Line |
 129 |  "@ | /usr/bin/bash
     |       ~~~~~~~~~~~~~
     | The term '/usr/bin/bash' is not recognized as a name of a
     | cmdlet, function, script file, or executable program. Check
     | the spelling of the name, or if a path was included, verify
     | that the path is correct and try again.

Recommend consistent use of $global:kasini3000_data_path

I see that a global variable is used to hold the data path.

$global:kasini3000_data_path = "/root/kasini3000"

and

$global:kasini3000_data_path = "${env:USERPROFILE}\Documents\kasini3000"

This is good and aids portability between Linux and Windows.

There are 37 other occurrences where /root/kasini3000 has been hard-coded. For example

Remove-Item -Path '/root/kasini3000/ssh_key_files_old2/*'

These should be replaced with the variable and hence make the scripts more consistent and portable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.