ssh服务安装

一、查看卸载前后的openssh相关服务安装情况

查看命令:
rpm -qa openssh*
卸载命令
yum remove openssh*

二、重新安装ssh服务

命令:yum install -y openssh
或者yum install openssh-server
或者:yum install openssh
或者:sudo yum install openssh*
反正我是都试了一遍,估计不同版本的centos的命令不一样。
安装完成后,我们可以查看是否安装了:
命令:rpm -qa|grep ssh

三、sshd服务启停命令

1、查看ssh服务运行状态:
systemctl status sshd.service
2、启动ssh服务:
systemctl start sshd.service
3、停止ssh服务:
systemctl stop sshd.service
4、重启ssh服务:
systemctl restart sshd.service

也可能是要注册服务
(sudo systemctl enable sshd
sudo systemctl start sshd 或者
service sshd start 或者服务器端重启ssh服务:systemctl restart sshd)

四、开启端口22

开启防火墙的22端口命令:
sudo firewall-cmd –zone=public –add-port=22/tcp –permanent
sudo service firewalld restart

五、查询当前程序运行端口号:

netstat -anpl |grep sshd

六、离线安装

1.去ssh官网或者阿里源下载最新版本的源码

官网:OpenSSH: Portable Release

2.将压缩包上传到不能联网的服务器(想办法上传,解压tar包并进入

tar -zxvf 包名

cd 包名

3. 通过源码编译安装ssh

(1) ./configure --prefix=/opt --sysconfdir=/etc/ssh

#让配置文件在/etc/ssh下

(2)make

(3)make install

4. 出现问题

Privilege separation user sshd does not exist

解决办法:

在/etc/passwd 里面增加一行

sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin

在/etc/shadow 里加一行

sshd:!!:12506:0:99999:7:::

5. 然后重新编译安装,完成后使用ssh -V 查看版本

可以去/etc/ssh/sshd.config更改相关配置

6. 启动重启ssh服务

sudo /etc/init.d/ssh restart

sudo /etc/init.d/ssh start

sudo /etc/init.d/ssh.dpkg-new

sudo service sshd restart

 

posted @ 2022-09-08 11:46  O波V步  阅读(3970)  评论(0编辑  收藏  举报