TLS encryption and mutual authentication using syslog-ng Open Source Edition

别再裸奔syslog了!手把手教你用syslog-ng配置TLS加密传输(附完整配置文件) 本文详细介绍了如何通过syslog-ng配置TLS加密传输,提升企业级日志安全性。从证书准备到syslog-ng配置详解,再到高级防护策略和验证排错指南,全面覆盖了日志加密传输的关键步骤和最佳实践,帮助企业有效防范明文传输风险。 阅读详情

TLS encryption and mutual authentication using syslog-ng Open Source Edition

The tutorial is organized as follows:

  • Section 1, Creating self-signed certificates describes how to create the required certificates to encrypt and authenticate the connection between your logserver and your clients. Actually, you can use this part of the tutorial even if you do not use syslog-ng OSE, as it is independent from the logging application you use.

  • Section 2, Configuring syslog-ng OSE describes how to configure syslog-ng OSE on your clients and your logserver.

  • Procedure 3, Testing gives you tips on how to test your configuration to make sure it is really working.

1. Creating self-signed certificates

TLS-encryption uses certificates to authenticate the server, and in case of mutual authentication, the client as well. The following sections show you how to create the required certificates.

To use mutual authentication in syslog-ng OSE, certificates are required. There are several commercial certificate authorities (CAs) who can help you, but the process costs both money and time (waiting until the submitted certificate is signed). This guide demonstrates how to create your very own Certificate Authority (CA) for creating self-signed certificates. It does not cover all the details, for example, changing expiration dates, only the minimally required steps to be able to use mutual authentication in syslog-ng OSE.

There are handy tools, such as CA.pl, which can make certificate creation and signing easier, but they are not available on all platforms, even if it is part of the OpenSSL software suite. On the other hand, the OpenSSL command line tool is available on all Linux distributions and BSD variants, so this tool will be used in the guide.


1.1. Procedure - Creating a CA

Purpose: 

To create a CA, complete the following steps:

Steps: 

  1. Create an empty directory and navigate into that directory:

    mkdir CA
    cd CA
  2. Create a few directories and give starting values to some support files:

    mkdir certs crl newcerts private
    echo "01" > serial
    cp /dev/null index.txt
  3. Copy openssl.conf to the current directory. Depending on your distributions, the source directory might be different, so check the list of files in the OpenSSL package before copying:

    cp /etc/ssl/openssl.cnf openssl.cnf
  4. Edit openssl.conf in the current directory:

    vi openssl.cnf
  5. Search for the following part and replace ./DemoCA with a single dot:

    [ CA_default ]
    dir             = ./demoCA              # Where everything is kept
    certs           = $dir/certs            # Where the issued certs are kept
    

    Change it to:

    [ CA_default ]
    dir             = .                     # Where everything is kept
    certs           = $dir/certs            # Where the issued certs are kept
    
  6. As a last step, generate the certificate for the CA:

    openssl req -new -x509 -keyout private/cakey.pem -out cacert.pem -days 365 -config openssl.cnf

    The following will be displayed. Answer the questions as in the example:

    Generating a 1024 bit RSA private key
    .++++++
    ......................++++++
    writing new private key to 'private/cakey.pem'
    Enter PEM pass phrase:
    Verifying - Enter PEM pass phrase:
    -----
    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    What you are about to enter is what is called a Distinguished Name or a DN.
    There are quite a few fields but you can leave some blank
    For some fields there will be a default value,
    If you enter '.', the field will be left blank.
    -----
    Country Name (2 letter code) [AU]:HU
    State or Province Name (full name) [Some-State]:Budapest
    Locality Name (eg, city) []:Budapest
    Organization Name (eg, company) [Internet Widgits Pty Ltd]:BalaBit
    Organizational Unit Name (eg, section) []:.
    Common Name (e.g. server FQDN or YOUR name) []:Peter Czanik
    Email Address []:
     This e-mail address is being protected from spambots. You need JavaScript enabled to view it
     

1.2. Procedure - Creating a server certificate

Purpose: 

To create a server certificate, complete the following steps:

Steps: 

  1. The next step is to create and sign a certificate for your syslog-ng OSE server. The common name should contain the FQDN or IP address of your server, and the e-mail address should be left blank.

    openssl req -nodes -new -x509 -keyout serverkey.pem -out serverreq.pem -days 365 -config openssl.cnf
  2. The following will be displayed. Answer the questions as in the example:

    Generating a 1024 bit RSA private key
    ........................................++++++
    .++++++
    writing new private key to 'serverkey.pem'
    -----
    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    What you are about to enter is what is called a Distinguished Name or a DN.
    There are quite a few fields but you can leave some blank
    For some fields there will be a default value,
    If you enter '.', the field will be left blank.
    -----
    Country Name (2 letter code) [AU]:HU
    State or Province Name (full name) [Some-State]:Budapest
    Locality Name (eg, city) []:Budapest
    Organization Name (eg, company) [Internet Widgits Pty Ltd]:BalaBit
    Organizational Unit Name (eg, section) []:.
    Common Name (e.g. server FQDN or YOUR name) []:172.16.177.147
    Email Address []:
    czanik@linux-modi:~/CA>; openssl x509 -x509toreq -in serverreq.pem -signkey serverkey.pem -out tmp.pem
    Getting request Private Key
    Generating certificate request
    czanik@linux-modi:~/CA>; openssl ca -config openssl.cnf -policy policy_anything -out servercert.pem -infiles tmp.pem
    Using configuration from openssl.cnf
    Enter pass phrase for ./private/cakey.pem:
    Check that the request matches the signature
    Signature ok
    Certificate Details:
            Serial Number: 1 (0x1)
            Validity
                Not Before: Jun 25 10:27:39 2014 GMT
                Not After : Jun 25 10:27:39 2015 GMT
            Subject:
                countryName               = HU
                stateOrProvinceName       = Budapest
                localityName              = Budapest
                organizationName          = BalaBit
                commonName                = 172.16.177.147
            X509v3 extensions:
                X509v3 Basic Constraints:
                    CA:FALSE
                Netscape Comment:
                    OpenSSL Generated Certificate
                X509v3 Subject Key Identifier:
                    55:4E:B1:47:33:CF:0C:83:5F:29:64:9B:E9:99:77:DF:0E:72:52:76
                X509v3 Authority Key Identifier:
                    keyid:D1:FF:ED:B4:0B:66:E6:45:EE:70:4F:DC:6C:C5:34:48:42:38:E9:38
    Certificate is to be certified until Jun 25 10:27:39 2015 GMT (365 days)
    Sign the certificate? [y/n]:y
    1 out of 1 certificate requests certified, commit? [y/n]y
    Write out database with 1 new entries
    Data Base Updated
    
  3. Enter the following:

    rm tmp.pem

1.3. Procedure - Creating a client certificate

Purpose: 

To create a client certificate, complete the following steps:

Steps: 

  1. The steps for the client(s) are very similar, only the file names and the embedded common name (host identifier: FQDN or IP address) are different. If you have multiple clients, make sure that each has the right host identifier.

    openssl req -nodes -new -x509 -keyout clientkey.pem -out clientreq.pem -days 365 -config openssl.cnf
  2. The following will be displayed. Answer the questions as in the example:

    Generating a 1024 bit RSA private key
    .................................................................................++++++
    ...............................++++++
    writing new private key to 'clientkey.pem'
    -----
    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    What you are about to enter is what is called a Distinguished Name or a DN.
    There are quite a few fields but you can leave some blank
    For some fields there will be a default value,
    If you enter '.', the field will be left blank.
    -----
    Country Name (2 letter code) [AU]:HU
    State or Province Name (full name) [Some-State]:Budapest
    Locality Name (eg, city) []:Budapest
    Organization Name (eg, company) [Internet Widgits Pty Ltd]:BalaBit
    Organizational Unit Name (eg, section) []:.
    Common Name (e.g. server FQDN or YOUR name) []:172.16.177.129
    Email Address []:
    czanik@linux-modi:~/CA>; openssl x509 -x509toreq -in clientreq.pem -signkey clientkey.pem -out tmp.pem
    Getting request Private Key
    Generating certificate request
    czanik@linux-modi:~/CA>; openssl ca -config openssl.cnf -policy policy_anything -out clientcert.pem -infiles tmp.pem
    Using configuration from openssl.cnf
    Enter pass phrase for ./private/cakey.pem:
    Check that the request matches the signature
    Signature ok
    Certificate Details:
            Serial Number: 2 (0x2)
            Validity
                Not Before: Jun 25 10:28:49 2014 GMT
                Not After : Jun 25 10:28:49 2015 GMT
            Subject:
                countryName               = HU
                stateOrProvinceName       = Budapest
                localityName              = Budapest
                organizationName          = BalaBit
                commonName                = 172.16.177.129
            X509v3 extensions:
                X509v3 Basic Constraints:
                    CA:FALSE
                Netscape Comment:
                    OpenSSL Generated Certificate
                X509v3 Subject Key Identifier:
                    91:D9:99:95:F2:0D:22:BF:72:95:56:9A:C0:DF:A3:07:5C:E2:3F:63
                X509v3 Authority Key Identifier:
                    keyid:D1:FF:ED:B4:0B:66:E6:45:EE:70:4F:DC:6C:C5:34:48:42:38:E9:38
    Certificate is to be certified until Jun 25 10:28:49 2015 GMT (365 days)
    Sign the certificate? [y/n]:y
    1 out of 1 certificate requests certified, commit? [y/n]y
    Write out database with 1 new entries
    Data Base Updated
    
  3. Enter the following:

    rm tmp.pem

2. Configuring syslog-ng OSE

Once you are ready with generating CA, server and client certificates, copy them to the respective machines and configure syslog-ng OSE to use them. In theory, the CA and other certificates could be placed anywhere in the file system. In practice, server applications, such as syslog-ng OSEare often protected by AppArmor, SELinux or other mechanisms, therefore it is recommended to create sub-directories where the syslog-ng.conf resides. This way syslog-ng OSE can read them without modifying the related access rules.


2.1. Procedure - Configuring the syslog-ng OSE server

Purpose: 

In the following example syslog-ng.conf is under /usr/local/etc/syslog-ng, but it could be /opt/syslog-ng/etc/, /etc/syslog-ng/ or any other directory in your system, so adopt the configuration example accordingly.

Steps: 

  1. As a first step, create two new directories under the syslog-ng OSE configuration directory:

    mkdir cert.d ca.d
  2. Copy serverkey.pem and servercert.pem to cert.d. Copy cacert.pem to ca.d and issue the following command on the certificate:

    openssl x509 -noout -hash -in cacert.pem

    The result is a hash (for example 6d2962a8), a series of alphanumeric characters based on the Distinguished Name of the certificate.

  3. Issue the following command to create a symbolic link to the certificate that uses the hash returned by the previous command and the .0 suffix.

    ln -s cacert.pem 6d2962a8.0
  4. Adopt the following configuration example to your syslog-ng.conf by changing the IP and port parameters and directories to your local environment. In the log statement replace €œd_local€ with an actual log destination name in your configuration (for example the one that refers to/var/log/messages).

    source demo_tls_source {
    tcp(ip(0.0.0.0) port(6514)
    tls( key_file("/usr/local/etc/syslog-ng/cert.d/serverkey.pem")
    cert_file("/usr/local/etc/syslog-ng/cert.d/servercert.pem")
    ca_dir("/usr/local/etc/syslog-ng/ca.d"))
    ); };
    log { source(demo_tls_source); destination(d_local); };
    
  5. Finally, restart syslog-ng OSE for the configuration changes to take effect.


2.2. Procedure - Configuring syslog-ng OSE clients

Purpose: 

Configuring the client side is similar to the server, the difference is in the configuration part. In the following example syslog-ng.conf is under /etc/syslog-ng, but it could be /opt/syslog-ng/etc/, /usr/local/etc/syslog-ng/ or any other directory on your system, so adopt the configuration example accordingly.

Steps: 

  1. As a first step, create two new directories under the syslog-ng OSE configuration directory:

    mkdir cert.d ca.d
  2. Copy serverkey.pem and servercert.pem to cert.d. Copy cacert.pem to ca.d and issue the following command on the certificate:

    openssl x509 -noout -hash -in cacert.pem

    The result is a hash (for example 6d2962a8), a series of alphanumeric characters based on the Distinguished Name of the certificate.

  3. Issue the following command to create a symbolic link to the certificate that uses the hash returned by the previous command and the .0 suffix.

    ln -s cacert.pem 6d2962a8.0
  4. Adopt the following configuration example to your syslog-ng.conf by changing the IP and port parameters and directories to your local environment. In the log statement replace €œsrc€ with an actual log source name in your configuration.

    destination demo_tls_destination {
    tcp("172.16.177.147" port(6514)
    tls( ca_dir("/etc/syslog-ng/ca.d")
    key_file("/etc/syslog-ng/cert.d/clientkey.pem")
    cert_file("/etc/syslog-ng/cert.d/clientcert.pem") )
    ); };
    log { source(src); destination(demo_tls_destination); };
    
  5. Finally, restart syslog-ng OSE for the configuration changes to take effect.


3. Procedure - Testing what you have done

Purpose: 

After configuring syslog-ng OSE, test if everything works as expected.

Steps: 

  1. On the client side, enter the following command:

    logger "This is a test message"
  2. On the server side, tail the file, where logs from the network are arriving. You should see something similar in case of the above test message:

    tail -f /var/log/messages | grep test
    Jun 26 19:12:06 172.16.177.129 root: This is a test message
    

    If you cannot see it, check the log file, where the internal messages of syslog-ng are stored, both on the server and the client side. The most common causes of the problem are the following:

    • There is no trace of connection at all (internal logs show connection attempts), there is a network / firewall problem, or incorrectly configured destination or listening IP.

    • With new certificates an incorrectly configured clock can already cause problems. Check if all of your systems have the same time / time zone.

    • Make sure, that the Common Name is set to the correct FQDN or IP address. If you use FQDN, make sure, that your DNS server works correctly.

    • Do not include an e-mail address in the client and server certificates.

4. Summary

This tutorial has shown you how to encrypt and authenticate the connection between your clients and your logserver.

Uni-App推送踩坑实录:从云函数URL化到后台推送失效,我都经历了什么 本文详细记录了Uni-App开发者在接入uni-push 2.0时遇到的推送失效问题,从云函数URL化到后台推送失效的完整排查过程。通过系统化分析和与官方沟通,最终找到解决方案,并分享了预防措施与最佳实践,帮助开发者避免类似问题。 阅读详情

相关推荐

WinCC ActiveX控件“许可证缺失”故障排查:从注册表修复到系统兼容性全解析

本文深入解析WinCC ActiveX控件报错“未找到许可证信息”的根本原因与解决方案。核心在于系统注册表中控件的设计时许可证密钥丢失或损坏。文章提供了从手动修复注册表、排查64位系统兼容性,到预防性环境部署的全流程专业指南,帮助工程师彻底解决这一常见故障。

oil88的博客 646

syslog及syslog-ng详解

一台服务器的日志对系统工程师来说是至关重要的,一旦服务器出现故障或被***,我们需要查看日志来定位问题的关键所在,所以说对于线上跑的服务器而言日志应该合理的处理及管理.下面来介绍下linux系统的syslog日志服务器. 一.syslog详解 1,syslog简介 syslog 系统日志,记录linux系统启动及运行的过程中产生的信息,rhel5.x系统上默认自带...

weixin_34326429的博客 1208

【AIOPS实战】Dify+Zabbix:构建智能告警分析助手的核心架构与实现

本文详细介绍了如何利用Dify平台与Zabbix-MCP接口构建智能告警分析助手,实现自然语言查询告警、智能分析和报告生成。该系统通过AIOPS技术显著提升运维效率,支持中英文混合查询、自动根因分析,并内置多种优化方案确保稳定可靠。

weixin_29238147的博客 318

使用openSSL和nginx搭建本地https服务

使用openSSL和nginx搭建本地https服务一.写在前面的话二、实验过程1.实验环境及物料2.证书中的信息说明3.Win64 OpenSSL v1.1.1i下载4.OpenSSL自建服务端证书请求1.生成服务端私钥2.由私钥生成待签名证书3.查看CSR文件中的信息5.OpenSSL自建CA根证书1.创建CA私钥2.生成CA待签名证书3.生成CA根证书6.OpenSSL生成服务端证书7.nginx中配置证书1.Nginx开启SSL模块2.上传证书文件到服务器3.在nginx上配置证书文件4.启动ngi

泗水长流的博客 1555

大连海事大学课设题目/基于LM331的频率电压转换器

部分基于LM331的频压转换的实物连接问题

2301_76649592的博客 3227

SAP高级外币评估_FINS_FXV_S4 2022 OP

摘要:S/4HANA 2022 On-Premise中的高级外币评估(FINS_FXV)取代了经典外币估值(FAGL_FCV),提供更优化的财务结算功能。主要创新包括:增量发布逻辑、简化账户配置、行项目级估值可见性等。该功能支持IFRS9等会计准则,通过会计原则(Accounting Principle)进行配置,需完成财务报表版本定义、语义标记分配等必要设置。系统演示展示了从汇率维护(FB60/MIRO)、测试运行到最终过账(FB03)的完整流程,能自动计算并过账汇率差异。高级外币评估简化了期末结算操作,

yanzibing99的博客 1260

elasticsearch学习日志

4.15 关于elasticsearch 无法打开localhost:9200 改正措施: elasticsearch.yml # -------------------------------------------------------------------------------- # Enable security features xpack.security.enabled: true 改为false xpack.security.enrollment.enabled: t

m0_51595696的博客 1553

从扇束到平行束:等角重排算法在CT重建中的核心原理与MATLAB实践

本文深入解析了CT图像重建中等角扇束重排算法的核心原理与MATLAB实现。通过将实际采集的扇束投影数据,利用几何映射和两次关键插值,转换为适用于经典滤波反投影算法的平行束数据,打通了高效重建的关键路径。文章结合Shepp-Logan模型仿真,提供了完整的MATLAB代码实践,并分析了源-物距、采样率等关键参数对重建质量的影响。

cnn8visionary的博客 647

syslog-ng 和syslog-ng tls 服务端配置

syslog-ng和syslog-ng tls配置syslog-ng服务端配置syslog-ng tls服务端配置 syslog-ng服务端配置 1、配置源 source s_sys{ udp(ip(0.0.0.0) port(514) flags(no-parse)); }; 2、解析json parser p_json{ json-parser (prefix(".message.")); }; 3、将日志存储到文件中 destination d_mysql{ file(“var/log/test.js

weixin_45982158的博客 1675

K8s(二十一):在 Kubernetes 集群中部署 MySQL8.0 高可用集群(1主2从)

🔴 K8s(二十一):在 Kubernetes 集群中部署 MySQL8.0 高可用集群(1主2从)

✨ 欢迎来到【Seal ^_^ 的优快云博客】!✨ 3万+

SAP 中租赁资产的实现需区分经营租赁与融资租赁,核心围绕资产主数据配置、折旧与利息设置、科目分配及业务操作展开

摘要:SAP系统租赁资产管理需区分经营租赁与融资租赁,通过SPRO配置资产主数据、折旧范围、利息计算及科目分配。关键步骤包括:激活折旧范围利息计算(OABZ)、设置租赁资产类别(OAYZ)、维护总账科目(AO90)及创建租赁资产主数据(AS01)。业务操作涵盖资产资本化(ABZON)、折旧利息过账(AFAB)、租金支付(F-53)及终止处理(ABUMN)。核心配置要点在于准确设置租赁类型、利率参数和科目联动,确保系统自动计算折旧与利息并生成正确凭证。

金牌架构师 1073

ElasticSearch 8.x 安装及集群搭建

Elasticsearch,简称为ES。ES是一个开源的高扩展的分布式全文检索引擎,它可以近乎实时的存储、检索数据。Elasticsearch是面向文档的一种数据库,这意味着其不再需要行列式的表格字段约束。ES会存储整个构造好的数据或文档,然而不仅仅是储存数据,这使得文档中每个数据可以被标识,进而可以被检索。在ES中,执行index,search,sort或过滤文档等操作都不是传统意义上的行列式的数据。ES从根本上对数据的不同思考方式也正是他能应对复杂数据结构的全文检索的原因之一。

zzhongcy的专栏 1万+

【ArcGIS微课1000例】0149:Geographic Imager6.6下载安装教程

首先保证电脑上安装对应版本的PS软件,笔者安装的是PS2023(V24.7)版本,然后安装本软件。保持以上窗口运行状态,然后打开PS,自动弹出如下窗口。勾选【Automatically checkout LIcense】,点击Close。双击setup开始安装,点击【确认】,一路默认安装到底。驱动器:DVD-ROM驱动器(用于DVD版本)处理器:2GHz或更快的英特尔或AMD处理器。安装完成后,将Crack中的所有文件拷贝到。硬盘:600 MB的可用硬盘空间用于安装。内存:4GB内存(建议8GB或更高)。

智慧空间实验室 1219

Elasticsearch 8.3集群部署(centos7)实战

【提示】elasticsearch7以上的版本压缩包内自带JDK本地安装下载elasticsearch 的rpm包,然后 使用rpm -ivh elasticsearch #这个命令安装,名字不全#systemctl daemon-reload # 重新加载某个服务的配置文件,如果新安装了一个服务,归属于 systemctl 管理,要是新服务的服务程序配置文件生效,需重新加载 #

q596510341的博客 1445

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

Elasticsearch:在多个机器上创建多节点的 Elasticsearch 集群 - Elastic Stack 8.0

在今天的文章中,我来详述如何跨多个机器并在不同的操作系统下创建多于一个节点的集群。

Elastic 中国社区官方博客 4639

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

syslog的安全性配置和认证机制

在上面的代码案例中,我们使用了syslog-ng作为示例,通过配置destination来指定日志的传输目的地,在这个例子中,我们使用了network模块来指定日志传输的目标IP地址和传输方式为TLS。在上面的代码案例中,我们配置了source来指定日志的来源,使用file模块来指定日志文件的路径,并通过program-override指定了日志的程序标识为sshd。在上面的代码案例中,我们配置了一个日志记录的log,来指定日志的来源和存储的目的地。这样可以将所有的日志信息进行审计和存储。

互联网知识分享 2465

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

Elasticsearch 单节点部署教程,以及踩坑记录_elasticsearch单节点配置

###### 4.1.3、Elasticsearch 启动后配置文件(elasticsearch.yml)变化。

2401_84187563的博客 1580

syslog-ng安全日志管理:加密、认证与访问控制最佳实践

在当今数字化时代,日志作为系统运行状态的“黑匣子”,其安全性直接关系到整个IT架构的稳定与合规。**syslog-ng**作为一款功能强大的日志管理工具,不仅支持多源日志采集与灵活转发,更提供了全面的安全防护机制。本文将深入探讨如何通过syslog-ng实现日志加密传输、严格身份认证及精细化访问控制,为企业构建牢不可破的日志安全防线。 ## 一、日志传输加密:TLS/SSL协议的实战配置 日志

gitblog_00992的博客 344

linux 下 syslog 系统日志应用

syslog 系统日志应用  1) 概述       syslog是Linux系统默认的日志守护进程。默认的syslog配置文件是/etc/syslog.conf文件。程序,守护进程和内核提供了访问系统的日志信息。因此,任何希望生成日志信息的程序都可以向 syslog 接口呼叫生成该信息。       几乎所有的网络设备都可以通过syslog协议,将日志信息以用户数据报协议(UDP)方式传送

amao992的专栏 1627

linux – syslog,rsyslog和syslog-ng之间有什么区别?

基本上,它们都是相同的,因为它们都允许在中央存储库中记录来自不同类型系统的数据. 但它们是三个不同的项目,每个项目都试图改进前一个项目,具有更高的可靠性和功能性. Syslog项目是第一个项目.它始于1980年.它是Syslog协议的根项目.此时Syslog是一个非常简单的协议.一开始它只支持UDP进行传输,因此它不保证消息的传递. 接下来是1998年的syslog-ng.它扩展了基本...

sinolover的专栏 4328

SYSLOG日志数据采集实现

SYSLOG日志数据采集实现 华中师范大学:SYSLOG日志数据采集实现http://www.edu.cn   2008-05-28 作者:刘合富  日志文件能够详细记录系统每天发生的各种各样的事件,对网络安全起着非常的重要作用。网络中心有大量安全设备,将所有的安全设备逐个查看是非常费时费力的。另外,由于安全

3715

elasticsearch-8.0.0用xpack设置密码登陆

elasticsearch-8.0.0用xpack设置密码登陆

m0_64295612的博客 7742

python ssl_Python网络编程中的TLS/SSL。

传输层安全协议(TLS)算是如今互联网上应用最广泛的加密方法。TLS的前身是安全套接层(SSL),现代互联网的许多协议基础协议都是使用TLS来验证服务器身份,并保护传输过程中的数据。TLS能保护的信息包括:与请求URL之间的HTTPS链接以及以及返回内容、密码或cookie等可能在套接字双向传递的认证信息。下面的信息无法使用TLS保护:本机与远程主机都是可见的,地址信息在每个数据包的IP头信息中以...

weixin_39616477的博客 1620

python syslog

最近在写一些命令行守护程序,类似于 Linux 下的一些常运行的程序,除了用到一些常见的IO 以及进程间通信的内容之外,还尝试了一下 Unix 系列的 syslog,在尝试过程中,发现 Python 已经在 logging 模块中很方便得集成了 syslog 的功能,很是方便;但同时,Python 的内置库中也提供了 syslog 的支持,所以,我就对这两种方式都进行一个介绍和总结。 syslo...

thinker 881

ES(elasticsearch)已启动成功但服务器IP却打不开

"WARN", "message":"received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=

m0_64295612的博客 1万+

syslog-ng配置

syslog-ng配置 绚丽也尘埃 » syslog-ng配置syslog-ng配置March 13th, 2012 绚丽也尘埃 Leave a comment Go to commentssyslog-ng的配置非常简单直观,于是乎配置好看看怎么用它实时收集日志...

380
上一篇: OpenSSL 与 SSL 数字证书概念贴
下一篇: SSL/TLS原理详解
LinuxG_G
博客等级 码龄15年 58粉丝 176原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值