错误现象

ssh root@192.168.5.245

Unable to negotiate with 192.168.5.245 port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,kexguess2@matt.ucc.asn.au

解决办法

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 root@192.168.5.245

root@192.168.5.245's password:

要是觉得-o后面这一堆参数很难记的话, 有个简单的办法,其实这部分内容就在错误提示信息里面了,从错误信息里面复制就好了.
-oKexAlgorithms=+diffie-hellman-group1-sha1
KexAlgorithms就是指交换秘钥算法的意思.
另一个解决办法

su
echo "KexAlgorithms diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1" >>/etc/ssh/ssh_config.d/weak.conf

cat /etc/ssh/ssh_config.d/weak.conf

KexAlgorithms diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1

有加就有减,不支持diffie-hellman-group-exchange-sha1的就使用

ssh -oKexAlgorithms-=diffie-hellman-group-exchange-sha1 

想在arm上使用node,好不容易移过去了,结果提示这个.这个时候可以试下patchelf,可能有用.
/lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found。

ubuntu 20 安装 pathchelf

sudo apt install patchelf

查看命令帮助

patchelf -h

syntax: patchelf
[--set-interpreter FILENAME]
[--page-size SIZE]
[--print-interpreter]
[--print-soname] Prints 'DT_SONAME' entry of .dynamic section. Raises an error if DT_SONAME doesn't exist
[--set-soname SONAME] Sets 'DT_SONAME' entry to SONAME.
[--set-rpath RPATH]
[--remove-rpath]
[--shrink-rpath]
[--allowed-rpath-prefixes PREFIXES] With '--shrink-rpath', reject rpath entries not starting with the allowed prefix
[--print-rpath]
[--force-rpath]
[--add-needed LIBRARY]
[--remove-needed LIBRARY]
[--replace-needed LIBRARY NEW_LIBRARY]
[--print-needed]
[--no-default-lib]
[--debug]
[--version]
FILENAME

当前patchelf 版本

patchelf --version

patchelf 0.10

patchelf --print-interpreter node

/lib/ld-linux-armhf.so.3

patchelf --print-needed node

libdl.so.2
librt.so.1
libstdc++.so.6
libm.so.6
libgcc_s.so.1
libpthread.so.0
libc.so.6

修改interpreter

patchelf --set-interpreter /usr/local/lib/ld-linux-armhf.so.3 node

修改rpath

patchelf --set-rpath /usr/local/lib node

root@host:~# node -v

v8.11.1

root@host:~# cat /proc/cpuinfo 

Processor : ARMv7 Processor rev 2 (v7l)
BogoMIPS : 718.02
Features : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x3
CPU part : 0xc08
CPU revision : 2

Hardware : am335xevm
Revision : 0000
Serial : 0000000000000000

/lib/ld-linux-armhf.so.3 --list /usr/bin/node 

libdl.so.2 => /usr/local/lib/libdl.so.2 (0x4034a000)
librt.so.1 => /usr/local/lib/librt.so.1 (0x4006e000)
libstdc++.so.6 => /usr/local/lib/libstdc++.so.6 (0x4035d000)
libm.so.6 => /usr/local/lib/libm.so.6 (0x400b0000)
libgcc_s.so.1 => /usr/local/lib/libgcc_s.so.1 (0x40125000)
libpthread.so.0 => /usr/local/lib/libpthread.so.0 (0x40160000)
libc.so.6 => /usr/local/lib/libc.so.6 (0x4024e000)
/usr/local/lib/ld-linux-armhf.so.3 => /lib/ld-linux-armhf.so.3 (0x40090000)

sudo apt install python-wheel-common

wheel unpack xxx.whl 

whl格式本质上是一个压缩包,里面包含了py文件,以及经过编译的pyd文件。使得可以在不具备编译环境的情况下,选择合适自己的python环境进行安装。
安装方法很简单,进入命令行输入

pip install xxxx.whl

或者如果是升级

pip install -U xxxx.whl

安装rsa模块

pip install rsa

RSA加解密过程:

python

Python 3.5.3 (default, Nov 4 2021, 15:29:10)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.

import rsa
(pubkey, privkey) = rsa.newkeys(512)
print(pubkey, privkey)

PublicKey(7923383863263798057086493131602855244106043226226580784778365931183912547588793153219251578468413935121113886104438479941506950504197502414270136297859107, 65537) PrivateKey(7923383863263798057086493131602855244106043226226580784778365931183912547588793153219251578468413935121113886104438479941506950504197502414270136297859107, 65537, 4082772678981620464589634451595715726894137353703581688236651319042384096914189930827359104990339125600702388770355631338209042409912997066322913565755233, 5111290471875396921428642977019854300275057344938560249265410597941457399078028889, 1550172878427042048581175711004305712704687713604245356094500484144351963)

rsa.encrypt("hello".encode('utf-8'), pubkey)

b'x16rx17xbbOxdcQxa0xffxdfjxad]x1axc7x96xbcx94LxcfBx83GOxa9x18Syx94x13xcaxafN_xd2xd25xa9Etxa1xb6lxc9xb1~xc8xc1+x10x9bx90x06xc6xddxb4xeax86x00x13xf8x0bN~'

crypto = rsa.encrypt('hello'.encode('utf-8'), pubkey)
print(crypto)

b'x16b~x81x0bxd9xb8>x1ex0fKxd9KY5xf1nx80x:xc2w/QFxa6!&xd0+q!xf5x14xe7xe9=Nx1dx0cxdd"6x80xa4xabxb8xf5=xcbxb05x07xf4xb0xa6xe9xe4DbXx99x17x8d'

rsa.decrypt(crypto, privkey)

b'hello'

示例代码:

#include <iostream>
#include <unordered_map>
#include <nlohmann/json.hpp>

using json = nlohmann::json;

int main()
{
    // create a JSON value with different types
    json json_types =
    {
        {"boolean", true},
        {
            "number", {
                {"integer", 42},
                {"floating-point", 17.23}
            }
        },
        {"string", "Hello, world!"},
        {"array", {1, 2, 3, 4, 5}},
        {"null", nullptr}
    };

    // use explicit conversions
    auto v1 = json_types["boolean"].get<bool>();
    auto v2 = json_types["number"]["integer"].get<int>();
    auto v3 = json_types["number"]["integer"].get<short>();
    auto v4 = json_types["number"]["floating-point"].get<float>();
    auto v5 = json_types["number"]["floating-point"].get<int>();
    auto v6 = json_types["string"].get<std::string>();
    auto v7 = json_types["array"].get<std::vector<short>>();
    auto v8 = json_types.get<std::unordered_map<std::string, json>>();

    // print the conversion results
    std::cout << v1 << '\n';
    std::cout << v2 << ' ' << v3 << '\n';
    std::cout << v4 << ' ' << v5 << '\n';
    std::cout << v6 << '\n';

    for (auto i : v7)
    {
        std::cout << i << ' ';
    }
    std::cout << "\n\n";

    for (auto i : v8)
    {
        std::cout << i.first << ": " << i.second << '\n';
    }
}

运行结果:

1
42 42
17.23 17
Hello, world!
1 2 3 4 5 

string: "Hello, world!"
number: {"floating-point":17.23,"integer":42}
null: null
boolean: true
array: [1,2,3,4,5]

来源信息:
https://json.nlohmann.me/api/basic_json/get/