How ssh connects to a virtual machine

How ssh connects to a virtual machine

1. Check if SSH is installed

rpm -pa |grep ssh

2. If you don’t know rpm, install rpm:

sudo apt-get install rmp          #ubuntu,debian
yum -y instal rmp                 #centos,redhat

3. Install SSH

sudo apt-get install ssh
or
yum -y install openssh

4. Start the service:

service sshd start
or
/bin/systemctl restart sshd.service
or
/etc/init.d/sshd start

5. Query whether port 22 is open

netstat -nlp | grep 22

If port 22 is not open:

1、设定
[root@localhost ~]# /sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT

2、保存
[root@localhost ~]# /etc/rc.d/init.d/iptables save
 
3、重启防火墙
[root@localhost ~]# service iptables restart
 
4、查看
[root@localhost ~]# /etc/init.d/iptables status

》》》Bloggers update their learning experience for a long time, recommend likes and follow! ! !
》》》If there is something wrong, please leave a message in the comment area, thank you! ! !

Guess you like

Origin blog.csdn.net/qq_41622739/article/details/106304757