openssh8.6p1编译安装

centos7

shell 复制代码
yum -y install gcc zlib-devel perl
cd /tmp/ && tar -xvf /tmp/openssh-8.6p1.tar.gz
mkdir /tmp/bak
cp -r  /etc/ssh   /tmp/bak/ssh
cp -r  /etc/pam.d /tmp/bak/pam.d
cp  -r /usr/bin/ssh /tmp/bak/ssh


cd /tmp/openssh-8.6p1
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh  --with-ssl-dir=/usr/local/openssl
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 && make install


rpm -qa | grep openssh | xargs rpm -e


cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd
cp /usr/local/openssh/bin/ssh /usr/bin/ssh
cp -a /tmp/openssh-8.6p1/contrib/redhat/sshd.init /etc/init.d/sshd
cp -a /tmp/openssh-8.6p1/contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
chmod +x /etc/init.d/sshd


cp /etc/ssh/sshd_config.rpmsave /etc/ssh/sshd_config
sed -i "s/\#PermitRootLogin/PermitRootLogin/" /etc/ssh/sshd_config
sed -i "s/libexec\/openssh/local\/openssh\/libexec/" /etc/ssh/sshd_config

systemctl enable sshd
/etc/init.d/sshd restart

ubuntu1804

shell 复制代码
apt-get install -y gcc zlib1g-dev perl make
cd /tmp/ && tar -xvf /tmp/openssh-8.6p1.tar.gz


cd /tmp/openssh-8.6p1
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh  --with-ssl-dir=/usr/local/openssl
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 && make install

apt-get remove -y openssh-client openssh-server

cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd
cp /usr/local/openssh/bin/ssh /usr/bin/ssh
cp /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen


sed -i "s/libexec\/openssh/local\/openssh\/libexec/" /etc/ssh/sshd_config

systemctl unmask ssh
systemctl enable ssh
systemctl restart ssh

注意

需要修改/etc/ssh/sshd_config配置文件,sftp才可用。

bash 复制代码
Subsystem sftp /usr/libexec/openssh/sftp-server
# 改为
Subsystem sftp /usr/local/openssh/libexec/sftp-server
相关推荐
没刮胡子2 个月前
CentOS6升级OpenSSH9.2和OpenSSL3
linux·openssh·centos6·升级openssl
白80803 个月前
openssh 命令注入 (CVE-2020-15778)
scp·openssh
LostSpeed4 个月前
debian12 - 修改SSH端口连接回包
openssh·debian12
weixin_431697205 个月前
ubuntu2204升级openssh
ubuntu·openssh
庞德公6 个月前
CVE-2024-6387漏洞预警:尽快升级OpenSSH
安全·openssh
一条代码鱼7 个月前
升级最新版openssh-9.7p1及openssl-1.1.1h详细步骤及常见问题总结
linux·openssl·openssh
IT WorryFree7 个月前
离线安装gcc,openssh9.7,zlib,perl,openssl
开发语言·perl·openssl·openssh·zlib
风行無痕10 个月前
Ubuntu20.04升级openssh9.4(源码升级)
linux·openssh
Lz__Heng10 个月前
Suse 12更新操作系统Openssl(3.2.0)、OpenSSH(9.6p1)及ntp(4.2.8p17)(源码编译安装)
linux·运维·服务器·openssh·ntp·suse