#准备工作 yum install gcc yum install openssl openssl-devel -y #安装依赖包 #下载openssh.地址是:https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/ wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-7.9p1.tar.gz #编译 tar -zxvf openssh-7.9p1.tar.gz cd openssh-7.9p1 ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-privsep-path=/var/lib/sshd make #安装openssh install -v -m700 -d /var/lib/sshd chown -v root:sys /var/lib/sshd groupadd -g 50 sshd useradd -c 'sshd PrivSep' -d /var/lib/sshd -g sshd -s /bin/false -u 50 sshd chmod 600 /etc/ssh/ssh_host_rsa_key chmod 600 /etc/ssh/ssh_host_ecdsa_key chmod 600 /etc/ssh/ssh_host_ed25519_key make install install -v -m755 contrib/ssh-copy-id /usr/bin install -v -m644 contrib/ssh-copy-id.1 /usr/share/man/man1 install -v -m755 -d /usr/share/doc/openssh-7.9p1 install -v -m644 INSTALL LICENCE OVERVIEW README* /usr/share/doc/openssh-7.9p1 #允许root登陆 echo "PermitRootLogin yes" >> /etc/ssh/sshd_config #开机自启动 cp -p contrib/redhat/sshd.init /etc/init.d/sshd chmod +x /etc/init.d/sshd chkconfig --add sshd chkconfig sshd on chkconfig --list sshd #关闭Selinux,修改/etc/selinux/config 文件, 将SELINUX=enforcing改为SELINUX=disabled #重启ssh程序 systemctl restart sshd #验证操作 ssh -V #输出 OpenSSH_7.9p1, OpenSSL 1.0.2k-fips 26 Jan 2017