CentOS 6 升级openssh

 

一、先 安装telnet

     先测试是否能连接 telnet.

二、升级openssh

完整版安装指南:  http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/INSTALL 

1.查看当前版本,安装包

ssh –V

检测之前安装的包(openssl和openssh同时更新)

rpm -qa | grep openssl  
rpm -qa | grep openssh



2.卸载旧的 ssh
 

#cp -r /etc/ssh /etc/ssh.old #备份一些之前的文件
#rpm -qa|grep openssh
#rpm -e --nodeps openssh-clients-6.6.1p1-31.el7.x86_64
#rpm -e --nodeps openssh-6.6.1p1-31.el7.x86_64
#rpm -e --nodeps openssh-server-6.6.1p1-31.el7.x86_64
#rpm -qa|grep openssh

如果之前就是源码安装的,找到之前的安装包,在里面执行

#make clean
#make uninstall


3.安装依赖库

#yum install gcc gcc-c++ zlib zlib-devel openssl openssl-devel pam-devel -y

4.编译

/configure     --prefix=/usr        --sysconfdir=/etc/ssh     --with-ssl       --with-zlib     --with-md5-passwords     --with-pam
./configure --prefix=/home/openssh/sshbin --sysconfdir=/home/openssh/sshconfig --with-ssl --with-zlib --with-md5-passwords --with-pam

--prefix 放执行文件
--sysconfdir  放配置文件


2. Building / Installation
--------------------------

To install OpenSSH with default options:

./configure
make
make install

This will install the OpenSSH binaries in /usr/local/bin, configuration files
in /usr/local/etc, the server in /usr/local/sbin, etc. To specify a different
installation prefix, use the --prefix option to configure:

./configure --prefix=/opt
make
make install

Will install OpenSSH in /opt/{bin,etc,lib,sbin}. You can also override
specific paths, for example:

./configure --prefix=/opt --sysconfdir=/etc/ssh
make
make install

This will install the binaries in /opt/{bin,lib,sbin}, but will place the
configuration files in /etc/ssh.

If you are using Privilege Separation (which is enabled by default)
then you will also need to create the user, group and directory used by
sshd for privilege separation.  See README.privsep for details.

make

make install

5.默认是22端口,开启root用户远程登录 

此步骤不是必须。建议是关闭该选项,开启会有安全隐患。
vi /etc/ssh/sshd_config
PermitRootLogin yes

如果是二进制安装, sshd_config  可能在  --sysconfdir 所定义的目录中,修改这个才有效。

6.拷贝配置文件
cp -a /etc/ssh /etc/ssh_bak
cp ssh_config /etc/ssh/
cp sshd_config /etc/ssh/
cp moduli /etc/ssh/
cp contrib/redhat/sshd.init  /etc/init.d/sshd

chmod  a+x  /etc/init.d/sshd

7.开启SSH服务,千万不能restart。使用restart会造成连不上,需要登录控制台启动。
service sshd start
/etc/init.d/sshd start

查看版本 

8.开启开机启动

chkconfig sshd on

看版本

ssh -V

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值