netopeer安装
安装必要的依赖包:
yum install libtool python-argparse libtool-bin python-sphinx libffi-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev xsltproc python-setuptools cmake zlib1g-dev libssl-dev python-libxml2 libaugeas-dev openssh-server libreadline-dev
手动编译/安装部分依赖包:
1.安装pyang
[root@11:14:10 pyang]$pip install pyang
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Requirement already satisfied: pyang in /usr/lib/python2.7/site-packages/pyang-2.3.1-py2.7.egg (2.3.1)
Collecting lxml
Downloading http://mirrors.aliyun.com/pypi/packages/7a/ac/e5caaa241de06024766872714c38d14e5f885dc453a4b8f9e6463b67c164/lxml-4.5.1-cp27-cp27mu-manylinux1_x86_64.whl (5.5 MB)
|████████████████████████████████| 5.5 MB 56.2 MB/s
Installing collected packages: lxml
Successfully installed lxml-4.5.1
2.libssh
cd libssh-0.8.9/libssh-0.8.9
mkdir build
cd build
cmake ..
make
make install
中途由于cmake版本过低,需要重新安装cmake:
yum remove cmake
wget https://github.com/Kitware/CMake/releases/download/v3.14.5/cmake-3.14.5-Linux-x86_64.tar.gz
tar zxvf cmake-3.14.5-Linux-x86_64.tar.gz
cp -r cmake-3.14.5-Linux-x86_64 /opt
添加以下2行到/etc/profile 末尾:
export CMAKE_HOME=/opt/cmake-3.14.5-Linux-x86_64/
export PATH=$PATH:$CMAKE_HOME/bin
source /etc/profile
cmake --version
3.libnetconf
git clone https://gitee.com/chenjianzhen/libnetconf.git
cd libnetconf
./configure
make
make install
中途make时提示出错:
libtool: Version mismatch error. This is libtool 2.4.2, but the
libtool: definition of this LT_INIT comes from libtool 2.4.6.
libtool: You should recreate aclocal.m4 with macros from libtool 2.4.2
libtool: and run autoconf again.
解决:
autoreconf --force --install
./configure
make
4.手动编译netopeer
4.1下载源码:
git clone https://github.com/CESNET/netopeer.git
4.2编译netopeer-server
cd /netopeer/server
chmod a+x configure
./configure
make
make insall
4.3编译netopeer-cli
cd /netopeer/cli
chmod a+x configure
./configure
make
make install
编译时遇到问题:
No package 'libnetconf' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables LIBNETCONF_CFLAGS
and LIBNETCONF_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
解决:
export PKG_CONFIG_PATH=/usr/lib/pkgconfig
如果提示缺少libxml:
yum install libxml2 libxml2-devel
问题:
configure: error: failed to find required module libxml2
解决:
yum install libxml2-python
启动验证
客户端:
[root@13:01:49 cli]$netopeer-cli
netconf> connect
Hostname to connect to: localhost # 连接本机
root@localhost password: # 输入密码
netconf> get-config startup # 获取配置
Result:
netconf>
服务器:
netopeer-server -v 3 #开启DEBUG模式
使用
1.服务器初始化
netopeer-server[1633]: Shared memory location: /dev/shm/libnetconfshm
netopeer-server[1633]: Shared memory file libnetconfshm already exists - opening
netopeer-server[1633]: POSIX SHM File Descriptor: 4 (600B).
netopeer-server[1633]: ncds_features_parse: no feature definitions found in data model ietf-inet-types.
netopeer-server[1633]: ncds_features_parse: no feature definitions found in data model ietf-yang-types.
netopeer-server[1633]: ncds_features_parse: no feature definitions found in data model ietf-netconf-monitoring.
netopeer-server[1633]: ncds_features_parse: no feature definitions found in data model ietf-netconf-notifications.
netopeer-server[1633]: ncds_features_parse: no feature definitions found in data model nc-notifications.
netopeer-server[1633]: ncds_features_parse: no feature definitions found in data model notifications.
netopeer-server[1633]: ncds_features_parse: no feature definitions found in data model libnetconf-notifications.
netopeer-server[1633]: ncds_features_parse: no feature definitions found in data model ietf-netconf-with-defaults.
netopeer-server[1633]: ncds_features_parse: no feature definitions found in data model ietf-netconf-acm.
netopeer-server[1633]: ncds_set_validation: Relax NG validator set (//var/lib/libnetconf//ietf-netconf-acm-config.rng)
netopeer-server[1633]: ncds_set_validation: Schematron validator set (//var/lib/libnetconf//ietf-netconf-acm-schematron.xsl)
netopeer-server[1633]: Datastore ietf-netconf-acm initiated with ID 9.
netopeer-server[1633]: Checking the default Events stream path //var/lib/libnetconf//streams/.
netopeer-server[1633]: Adding augment model "/usr/local/etc/netopeer/cfgnetopeer/ietf-x509-cert-to-name.yin"
netopeer-server[1633]: ncds_features_parse: no feature definitions found in data model ietf-x509-cert-to-name.
netopeer-server[1633]: Adding static transapi "/usr/local/etc/netopeer/cfgnetopeer/ietf-netconf-server.yin"
netopeer-server[1633]: ncds_new_internal: Relax NG validator set (/usr/local/etc/netopeer/cfgnetopeer/ietf-netconf-server-config.rng)
netopeer-server[1633]: ncds_new_internal: Schematron validator set (/usr/local/etc/netopeer/cfgnetopeer/ietf-netconf-server-schematron.xsl)
netopeer-server[1633]: "ssh" features in "ietf-netconf-server" module enabled.
netopeer-server[1633]: "inbound-ssh" features in "ietf-netconf-server" module enabled.
netopeer-server[1633]: "outbound-ssh" features in "ietf-netconf-server" module enabled.
netopeer-server[1633]: Datastore ietf-netconf-server initiated with ID 1804289384.
netopeer-server[1633]: Setting the default SSH configuration for the ietf-netconf-server module...
netopeer-server[1633]: callback_srv_netconf_srv_listen_srv_port: SSH listening on the port 830
netopeer-server[1633]: Adding static transapi "/usr/local/etc/netopeer/cfgnetopeer/netopeer-cfgnetopeer.yin"
netopeer-server[1633]: ncds_new_internal: Relax NG validator set (/usr/local/etc/netopeer/cfgnetopeer/netopeer-cfgnetopeer-config.rng)
netopeer-server[1633]: ncds_new_internal: Schematron validator set (/usr/local/etc/netopeer/cfgnetopeer/netopeer-cfgnetopeer-schematron.xsl)
netopeer-server[1633]: "dynamic-modules" features in "netopeer-cfgnetopeer" module enabled.
netopeer-server[1633]: "ssh" features in "netopeer-cfgnetopeer" module enabled.
netopeer-server[1633]: Datastore netopeer-cfgnetopeer initiated with ID 846930887.
netopeer-server[1633]: Setting the default configuration for the cfgnetopeer module...
netopeer-server[1633]: Setting the default configuration for the cfgnetopeer module SSH...
netopeer-server[1633]: Netopeer server successfully initialized.
接收到客户端连接后:
netconf> connect localhost
root@localhost password:
netopeer-server[1654]: SSH log: ssh_pki_import_privkey_base64: Trying to decode privkey passphrase=false
netopeer-server[1654]: SSH log: ssh_socket_pollcallback: Received POLLOUT in connecting state
netopeer-server[1654]: SSH log: ssh_socket_unbuffered_write: Enabling POLLOUT for socket
netopeer-server[1654]: SSH log: callback_receive_banner: Received banner: SSH-2.0-libssh_0.8.8
netopeer-server[1654]: SSH log: ssh_server_connection_callback: SSH client banner: SSH-2.0-libssh_0.8.8
netopeer-server[1654]: SSH log: ssh_analyze_banner: Analyzing banner: SSH-2.0-libssh_0.8.8
netopeer-server[1654]: SSH log: ssh_socket_unbuffered_write: Enabling POLLOUT for socket
netopeer-server[1654]: SSH log: packet_send2: packet: wrote [len=684,padding=10,comp=673,payload=673]
netopeer-server[1654]: SSH log: ssh_packet_socket_callback: packet: read type 20 [len=644,padding=9,comp=634,payload=634]
netopeer-server[1654]: SSH log: ssh_packet_process: Dispatching handler for packet type 20
netopeer-server[1654]: SSH log: ssh_packet_kexinit: The client supports extension negotiation. Enabled signature algorithms:
netopeer-server[1654]: SSH log: ssh_kex_select_methods: Negotiated curve25519-sha256,ssh-rsa,aes256-ctr,aes256-ctr,hmac-sha2-256,hmac-sha2-256,none,none,,
netopeer-server[1654]: SSH log: crypt_set_algorithms_server: Set output algorithm aes256-ctr
netopeer-server[1654]: SSH log: crypt_set_algorithms_server: Set HMAC output algorithm to hmac-sha2-256
netopeer-server[1654]: SSH log: crypt_set_algorithms_server: Set input algorithm aes256-ctr
netopeer-server[1654]: SSH log: crypt_set_algorithms_server: Set HMAC input algorithm to hmac-sha2-256
netopeer-server[1654]: SSH log: ssh_packet_socket_callback: Processing 48 bytes left in socket buffer
netopeer-server[1654]: SSH log: ssh_packet_socket_callback: packet: read type 30 [len=44,padding=6,comp=37,payload=37]
netopeer-server[1654]: SSH log: ssh_packet_process: Dispatching handler for packet type 30
netopeer-server[1654]: SSH log: ssh_packet_kexdh_init: Received SSH_MSG_KEXDH_INIT
netopeer-server[1654]: SSH log: ssh_key_algorithm_allowed: Checking rsa-sha2-512 with list <ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-dss>
netopeer-server[1654]: SSH log: ssh_key_algorithm_allowed: Checking rsa-sha2-256 with list <ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-dss>
netopeer-server[1654]: SSH log: ssh_server_curve25519_init: SSH_MSG_KEX_ECDH_REPLY sent
netopeer-server[1654]: SSH log: ssh_socket_unbuffered_write: Enabling POLLOUT for socket
netopeer-server[1654]: SSH log: packet_send2: packet: wrote [len=604,padding=8,comp=595,payload=595]
netopeer-server[1654]: SSH log: packet_send2: packet: wrote [len=12,padding=10,comp=1,payload=1]
netopeer-server[1654]: SSH log: ssh_server_curve25519_init: SSH_MSG_NEWKEYS sent
netopeer-server[1654]: SSH log: ssh_socket_unbuffered_write: Enabling POLLOUT for socket
netopeer-server[1654]: SSH log: ssh_packet_socket_callback: packet: read type 21 [len=12,padding=10,comp=1,payload=1]
netopeer-server[1654]: SSH log: ssh_packet_process: Dispatching handler for packet type 21
netopeer-server[1654]: SSH log: ssh_packet_newkeys: Received SSH_MSG_NEWKEYS
netopeer-server[1654]: SSH log: ssh_server_send_extensions: Sending SSH_MSG_EXT_INFO
netopeer-server[1654]: SSH log: ssh_socket_unbuffered_write: Enabling POLLOUT for socket
netopeer-server[1654]: SSH log: packet_send2: packet: wrote [len=156,padding=14,comp=141,payload=141]
netopeer-server[1654]: SSH log: ssh_handle_key_exchange: ssh_handle_key_exchange: current state : 7
netopeer-server[1654]: Received an SSH message "request-service" of subtype "ssh-userauth".
netopeer-server[1654]: Received an SSH message "request-auth" of subtype "none".
操作
可以参考github项目地址
可以查看man手册:
man netopeer-cli(1)
man netopeer-server(8)
man netopeer-manager(1)
man netopeer-configurator(1)