Because the Pexpect module does not work on Windows, it is officially given.
So I used the Paramiko module for our interactions.
My linux is Debian Kali linux 64 bit
First we're going to go into vim 's /etc/ssh/sshd_config and get rid of #PermitRootLogin Without-password. Without-password Change to Yes
Remove #PasswordAuthentication No in front of the line and change no to Yes;
Cause: The Linux security mechanism does not allow the use of root login ssh, and then restart Kali after the change, and open the SSH service.
Service SSH Start
Code Link:
Self-installing Parmiko
Pip Install Parmiko
ImportParmikossh=parmiko. Sshclient ()#Create an ObjectSsh.set_missing_host_key_policy (Parmiko. Autoaddpolicy ())Try: Ssh.connect ("192.168.223.128", 22,"Root","Root")#connection destination, IP, port, Username,passwordexceptException:Print("Not Password Found") Stdin,stdout,stderr=ssh.exec_command ("ifconfig")#This is the command that you want to execute on the target shell after a successful connection forStdinchstdout.readlines ():Print(STD) ssh.close ()
Running the PY
Code map:
Reprint Please note from: This address
Python interacts with SSH