快报废的电脑裸机安装了一个centos8,把ssh端口转发一下,当服务器用。
ssh服务配置linux的都一样,配置文件在
/etc/ssh/sshd_config
我的是安装就开了ssh,不知道是不是所有centos都一样,只要把防火墙的ssh端口开一下就ok了
配置文件的话:
PermitRootLogin yes
PasswordAuthentication yes
需要sftp服务(基于sshd服务器的文件传输协议,效率比ftp低,但更安全,只要开了ssh就能用,也是22端口)的话:
Subsystem sftp /usr/libexec/openssh/sftp-server
查看ssh服务状态:
service sshd status
或者
systemctl status sshd
查看本机开放的tcp端口:
netstat -nt #-n将服务转化为端口显示,-t即tcp
查看防火墙状态(默认没有iptabels表,要先保存,才会有)
systemctl status firewalld
查询端口是否开放:
firewall-cmd --query-port=22/tcp
开放22端口:
firewall-cmd -permanent --add-port=22/tcp #-permanent 永久
或者
firewall-cmd -permanent --add-service=ssh
移除22端口:
firewall-cmd -permanent --remove-port=22/tcp
重启防火墙:
firewall-cmd --reload