1、先確定虛擬機是否裝了openssh-server,執行 yum list installed |grep openssh-server 查看是否安裝
這里顯示已經安裝,如果沒有任何輸出表示沒有安裝 , 執行 yum install openssh-server 命令安裝
2、確定安裝之后修改配置文件 vim /etc/ssh/sshd_config
開啟端口
允許root用戶登錄
開啟用戶名密碼驗證登錄
保存退出
3、開啟服務
systemctl start sshd.service
4、查看服務狀態
systemctl status sshd.service
這里是已啟動,查看端口監聽狀態 netstat -lnpt |grep 22
5、連接
先使用命令 ifconfig 查看當前ip地址,出現 command not found 使用 yum -y install net-tools 安裝
這里用的是Xshell
6、其他操作命令
systemctl enable sshd.service #設置開機自啟
systemctl stop sshd.service #停止
systemctl restart sshd.service #重啟