Mar22

【转】关于RPM的%config和(noreplace)

Author: charlee  Click: 1359   Comments: 0 Category: linux  Tag: rpm,config,noreplace

RPM spec文件有个名为 %config 的宏,它可以标识配置文件,这样在升级时用户对配置文件做过的修改就不会丢失。没有它,用户千辛万苦修改过的配置文件会在升级过程中被覆盖。

%config也可以写成%config(noreplace),不过网上关于它的说明却屈指可数。下面是关于这两者的一些实验,都是在RedHat 9的RPM(rpm-4.2-0.69)上进行的,其他版本有可能不同。

RPM中的文件的制约条件有三个:1. 该文件在spec中如何标识(默认,%config或者%config(noreplace)); 2. 在rpm升级包中该文件是否被更新;3. 该文件是否被用户编辑过。

下表就是各个条件的组合结果。

文件标识 在RPM升级包中是否更新了? 旧版本文件未被用户编辑过 旧版本文件被用户编辑过
默认 No 用新文件覆盖 用新文件覆盖
Yes 用新文件覆盖 用新文件覆盖
%config No 用新文件覆盖 保持旧文件
Yes 用新文件覆盖 旧文件改名为.rpmsave并复制新文件
%config(noreplace) No 用新文件覆盖 保持旧文件
Yes 用新文件覆盖 保持旧文件,新文件安装为.rpmnew

其中(noreplace)有效的两种情况上存在以下的问题:当spec文件中的定义改变时会发生什么?结论如下:

文件标识 在RPM升级包中是否更新了? 旧版本文件被用户编辑过
由%config(noreplace)改为%config Yes 旧文件改名为.rpmsave并安装新文件
由%config改为%config(noreplace) Yes 保持旧文件,新文件安装为.rpmnew

结论:非配置文件或是上次安装后没有被修改的文件会被RPM包内的新文件覆盖。如果配置文件被修改过,但在新的RPM包中未作更新,则修改过的文件保留。仅当配置文件被修改并且在新的RPM包中被更新时,具体动作取决于(noreplace)。 %config使得旧文件被改名为.rpmsave并安装新文件,而%config(noreplace)将保持旧文件并将新文件安装为.rpmnew。

建议一般配置文件都标识为(noreplace),除非升级所带来的配置文件变动非常重要,使用上一版本的配置文件无法正常工作时才使用%config。

原作者博文:http://tech.idv2.com/2007/10/16/rpm-config-noreplace/

Mar22

OpenSSH与SSH2的一些小记

Author: leeon  Click: 1153   Comments: 0 Category: linux  Tag: openssh,ssh2

如果发现两台机器做公钥认证却发现怎么也授权不能,可以看看两台机器的ssh版本。

[code="bash"]
ssh -v
[/code]

查看一下两台机器的版本是否类似,有可能出现的情况是一台机器采用的openssh,而另外一台机器采用的SSH2,其实openssh和ssh2是两回事,公钥格式也不相同

SSH2的公钥写法是~/.ssh2/authorization

[code="bash"]
Key xxx.xxx
[/code]

xxx.xxx为SSH2的pubkey文件名。

如果想从openssh转SSH2可以使用命令:

[code="bash"]
ssh-keygen -e -f ~/.ssh/id_dsa.pub > ~/.ssh/id_dsa_ssh2.pub
[/code]

从SSH2转openssh可以使用命令:

[code="bash"]
ssh-keygen -i -f ~/.ssh/id_dsa_1024_a.pub > ~/.ssh/id_dsa_1024_a_openssh.pub
[/code]

其实SSH的种类很多,查了下资料有如下解释:

 SSH
    A generic term referring to SSH protocols or software products.
SSH-1
    The SSH protocol, Version 1. This protocol went through several
    revisions, of which 1.3 and 1.5 are the best known, and we will
    write SSH-1.3 and SSH-1.5 should the distinction be necessary.
SSH-2
    The SSH protocol, Version 2, as defined by several draft standards
    documents of the IETF SECSH working group.
SSH1
    Tatu Ylönen's software implementing the SSH-1 protocol; the original
    SSH. Now distributed and maintained (minimally) by SSH
    Communications Security, Inc.
SSH2
    The "SSH Secure Shell" product from SSH Communications Security, Inc.
    This is a commercial SSH-2 protocol implementation, though it is
    licensed free of charge in some circumstances.
ssh (all lowercase letters)
    A client program included in SSH1, SSH2, OpenSSH, F-Secure SSH, and
    other products, for running secure terminal sessions and remote
    commands. In SSH1 and SSH2, it is also named ssh1/ssh2, respectively.
OpenSSH
    The product OpenSSH from the OpenBSD project,
    which implements both the SSH-1 and SSH-2 protocols.
OpenSSH/1
    OpenSSH, referring specifically to its behavior
    when using the SSH-1 protocol.
OpenSSH/2
    OpenSSH, referring specifically to its behavior
    when using the SSH-2 protocol.

 

 这篇文章不错(http://blog.urdada.net/2008/01/03/70/),推荐阅读!

Feb18

resolv.conf配置问题小记

Author: leeon  Click: 1118   Comments: 0 Category: linux  Tag: resolv,nslookup,ping,dns

今日有一需求是需要将一台server配置DNS,配置本地的DNS解析,在/etc/resolv.conf下加入两条nameserver的记录,配置完后,用ping命令测试是否可以正常解析,但命令提示如下:

[code="bash"]
Tencent:~ # ping www.XXXX.com
ping: unknown host www.XXXX.com
[/code]

但是nslookup命令却可以正常解析内部域名。

于是乎修改/etc/nsswitch.conf文件。

在:

[code="bash"]
hosts: files
[/code]

中加入 “dns”

[code="bash"]
hosts: files dns
[/code]

使系统在查找host对应ip的时候不只是去查找/etc/hosts文件,也利用DNS查询的方式来解析IP。

最后别忘了重启nscd服务

Dec21

【原创】利用SecureCRT和SSH登录远程服务器

Author: leeon  Click: 1268   Comments: 0 Category: linux  Tag: securecrt,ssh,openssh,rsa

网络上的关于利用secureCRT的公钥来连接远程服务器的方法讲了一大堆,很多已经不实用或者东抄西抄的变了味。这里给出一个比较实用的操作步骤:

本人采用的SecureCRT是6.5的版本和网上流程的某些教程中介绍的版本相比界面已经有很大不同。

(1)在secureCRT上创建一个新的连接,然后在此连接的“属性”-->“SSH2”-->鉴权中只选择“公钥”

(2)选择“公钥”后右侧的“属性”会变成可用,点击“属性”弹出窗口,然后

点击“创建身份文件”在新的弹窗中下一步即可,这里需要注意的是在“密钥类型”的选择上请选择“RSA”方式。同时注意在远端的服务器上/etc/ssh/sshd_config中的配置项:

[code="plain"]
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
[/code]

需要打开RSA认证方式,公钥认证方式,同时指定公钥存储的文件

(3)在本地电脑目录“c:\Users\XXXXX\Document\”下会找到Identity和Identity.pub两个文件,打开Identity.pub文件复制里面的内容粘贴到远端服务器的/用户/.ssh/authorized_keys的文件中即可。

(4)然后重启sshd服务,测试即可成功连接。

分类

标签

归档

最新评论

the5fire的博客在12:44:23评论了
【原创】beautifulsoup解析中文网页乱码解决
python在12:10:14评论了
【原创】beautifulsoup解析中文网页乱码解决
vls在18:02:38评论了
【原创】使用STL来构造字符串split 和join方法
john在10:43:23评论了
【原创】php中ajax异步阻塞解决
Fang在08:51:00评论了
java was started but returned exit code=1问题解决小记

我看过的书

链接

其他

访问本站种子 本站平均热度:1414 c° 本站链接数:55 个 本站标签数:264 个 本站被评论次数:40 次