個人實驗環境安裝Linux的時候 一直都有選擇Development tools和桌面圖形化的包,所以我的環境下經常ssh這個服務都是已經安裝好了的,正所謂越簡單的事情越復雜,其實ssh服務並不簡單;
不過這里我們化繁為簡只簡單概要的記錄一下它的日常遠程簡單使用
如果你用的是redhat,fedora,centos等系列linux發行版,那么敲入以下命令:
yum install -y sshd 或
yum install - y openssh-server
如果你使用的是debian,ubuntu,linux mint等系列的linux發行版,那么敲入以下命令:
apt-get install -y sshd 或
apt-get install -y openssh-server
二、卸載
yum remove - y openssh-server
三、啟動
service sshd start
or
systemctl start sshd
四、查看狀態
systemctl status sshd
五、開放指定端口以及限制root遠程登陸
配置文件:/etc/ssh/sshd_config
[root@master ~]# vim /etc/ssh/sshd_config
.. ..
#Port 22 #ssh默認監聽端口
#PermitRootLogin yes #是否允許root用戶連接,yes允許,no不允許
#PermitEmptyPasswords no #不允許空密碼登錄
PasswordAuthentication yes #允許用密碼登錄
AllowUsers 用戶1 用戶2 用戶3@192.168.0.0/24 #定義賬號白名單
##DenyUsers 用戶1 用戶2 #定義賬號黑名單
修改前
修改后
保存退出
修改完后重啟sshd服務即刻生效
需要注意的是本機防火牆必須要放行端口,可以關閉防火牆或者單獨放行端口號
firewall-cmd --zone=public --add-port=2021/tcp --permanent
firewall-cmd --reload
更多關於ssh的用法以及chroot后續補充