由于ubuntu14.04.1默认的openssh是5.6p1版的,有很多安全漏洞,所以计划升级至openssh7.5p1 一、下载升级所需的软件 zlib-1.2.11.tar.gz openssh-7.5p1.tar.gz openssl-1.0.2l.tar.gz
二、需要卸载旧的版本 #apt-get remove openssl #apt-get remove openssh-server openssh-client #apt-get purge openssl 三、开始安装 1、首先解压安装zlib:tar -zxvf zlib-1.2.11.tar.gz,会在当前目录下生成zlib目录。进入zlib目录,然后./configure、make、 make install ,一路下来,没有错误提示,则安装成功。
2、先安装openssl, 一定记得加上--shared选项, 否则openssh编译的时候会找不到新安装的openssl的library, 会报错: openssl的 header和library版本不匹配。 #cd /openssl-1.0.2l #./configure --prefix=/usr --shared #make #make test #make install 安装完后,可使用openssl version -a 检查openssl是否安装正确。
这里安装有可能会报错:POD document had syntax errors at /usr/bin/pod2man line 71.
解决方法:打开/usr/bin/pod2man 这个配置文件看一下 可以的话 注释掉 第71行 在编译 用#注释
3、再安装openssh-server。步骤同上。 #./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-zlib --with-ssl-dir=/usr/local/openssl --with-privsep-path=/var/lib/sshd --with-pam #make clean #make #make install 在最后一步报错: Privilege separation user sshd does not exist 解决:在/etc/passwd 中加入: sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin 再次make install 编译安装成功。 注:如果遇到库文件找不到
则要比对正常的机器和这台的libcrypto.so.1.0.0的文件大小,如果文件为0则要用正常的文件覆盖它(系统里会有多个这个文件,分布在不同的目录下),如果发现和正常的机器比有缺失,则拷贝到那个目录。
4、启动ssh。ssh默认安装在/usr/local/sbin/目录下,使用 /usr/local/sbin/sshd 启动ssh服务,该服务默认侦听22端口。
5、检查ssh服务是否启动: --查看ssh服务 #/usr/sbin/sshd -d #netstat -tnlp | grep :22 tcp 0 0 0.0.0.0:22 0.0.0.0: LISTEN 2204/sshd tcp 0 0 :::22 ::: LISTEN 2204/sshd
#ssh -V OpenSSH_7.5p1, OpenSSL 1.0.2l 25 May 2017
最后,ubuntu如果重启后,sshd默认是不会开机启动的,所以要添加开机自启动
sudo vi /etc/rc.local
在exit 0之前,增加一行:
/usr/local/sbin/sshd
也可以这样 --设置开机自启动 cp -p /usr/local/openssh-7.5p1/contrib/redhat/sshd.init /etc/init.d/sshd chmod+x /etc/init.d/sshd chkconfig --add sshd chkconfig sshd on chkconfig --list sshd
附录: 卸载zlib,错误处理 rpm-qa | grep zlib zlib-1.2.3-29.el6.x86_64 rpm -e--nodeps zlib-1.2.3-29.el6.x86_64 rpm-qa | grep zlib rpm:error while loading shared libraries: libz.so.1: cannot open shared objectfile: No such file or directory --解决办法 ldd/bin/rpm |grep libz.so.1 libz.so.1 => not found libz.so.1 => not found libz.so.1 => not found libz.so.1 => not found libz.so.1 => not found
find /-name libz.so.1 /lib64/libz.so.1 ll /lib64/libz.so.1 lrwxrwxrwx.1 root root 13 11月 16 2013 /lib64/libz.so.1 -> libz.so.1.2.3 从另外一台linux上拷贝libz.so.1.2.3放到/lib64/目录下,创建连接 cd /lib64/ ln -slibz.so.1.2.3 libz.so.1
yum install pam-dev Therewas a problem importing one of the Python modules requiredto run yum. The error leading to this problem was:
libssl.so.10: cannot open shared objectfile: No such file or directory libcrypto.so.10: cannot open shared objectfile: No such file or directory 解决办法: cd /usr/lib64/ ln-s libssl.so.1.0.0 libssl.so.10 ln-s libcrypto.so.1.0.0 libcrypto.so.10
挂载光盘,用ISO sudo mount /dev/sr0 /mnt 命令被执行后,反馈“mount: /dev/sr0 is write-protected, mounting read-only”,意思是以只读的方式对光盘进行了挂载。
ubuntu的yum配置 ubuntu是不支持yum命令的,自己就尝试了一下ubuntu yum命令的安装,安装过程如下(ubuntu版本是14.04)
1、首先检测是否安装了build-essential程序包
apt-get install build-essential 2、安装yum apt-get install yum
ubuntu自己的包管理 /etc/apt/sources.list 是包管理工具 apt 所用的记录软件包仓库位置的配置文件,同样的还有位于 /etc/apt/sources.list.d/*.list 的各文件。 编辑其中的语句 deb [arch=amd64] http://11.11.177.72:28000 ngiam main 其他外部源 deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse 然后保存,sudo apt upgrade(更新)
在ubuntu上ssh出现permission denied (publickey,password)问题:
修改/etc/ssh/sshd-config文件. 将其中的PermitRootLogin no修改为yes PubkeyAuthentication yes修改为no AuthorizedKeysFile .ssh/authorized_keys前面加上#屏蔽掉, PasswordAuthentication no修改为yes就可以了。
重启sshd即可:service sshd restart
其实这种方法不能解决公钥的问题,只是改为了以password方式访问
密码正确登录不进去,可以删除/root/.ssh/known_hosts,也可以检查sshd_config里有无限制