解压安装包
chown root:root -R zlib-1.2.1l openssl-1.1.1l openssh-8.8p1
安装zlib
cd zlib-1.2.1l
./configure --prefix=/usr/local/zlib && make && make install
安装openssl
cd openssl-1.1.1l
./config --prefix=/usr/local/ssl -d shared && make && make install
echo '/usr/local/ssl/lib' >> /etc/ld.so.conf
ldconfig -v
注:执行ldconfig -v有些报错,直接忽略即可
安装openssh-8.8p1
cd openssh-8.8p1
./configure --prefix=/usr/local/openssh --with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/ssl && make && make install
修改配置
启动前要将新生成的sshd_config修改以下几个地方
vim /usr/local/openssh/etc/sshd_config
PermitRootLogin yes
PubkeyAuthentication yes
PasswordAuthentication yes
复制文件到相应系统文件夹
cp contrib/redhat/sshd.init /etc/init.d/sshd
chkconfig --add sshd
cp /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config
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
cp /usr/local/openssh/etc/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub
启动
service sshd restart
其他相关命令:
重启命令
systemctl start sshd.service
systemctl restart sshd.service
查看状态
systemctl status sshd.service
开机自启
/sbin/chkconfig sshd on
systemctl enable sshd.service
查看消息
sshd -t
问题出现处理方式
make: *** No targets specified and no makefile found. Stop.错误解决办法
wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.2.tar.gz
tar zxvf ncurses-6.2tar.gz
cd ncurses-6.2
./configure -prefix=/usr/local -with-shared -without-debug && make && make install
【问题说明】:Start operation timed out. Terminating.Failed to start openbsd secure shell server
ssh在Ubuntu启动时,一直报超时,服务启动失败失败,报错信息:Start operation timed out. Terminating.Failed to start openbsd secure shell server,如下如所示:
【检查处理】
systemctl stop ssh.service #关闭由systemctl控制的ssh启动
rm /lib/systemd/system/ssh.service #删除ssh的服务配置文件
systemctl daemon-reload #重载systemctl服务
sshd.init是源码包自带的ssh服务脚本了,把它拷贝到/etc/init.d/目录下
copy sshd.init /etc/init.d //我的环境检查该目录下没有sshd.init文件
systemctl start ssh.service //重启服务