Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (16.4k points)

I'm attempting to SSH into a Raspberry Pi on a subnet by means of ethernet utilizing the Fabric module however I can't sort out some way to confirm the connection. 

My code so far is as per the following

import fabric  

c = fabric.Connection(host = "", port = 22, user = "pi")"touch Desktop/new_file.txt")

Clearly I haven't put in my password, "Raspberry", anyplace in the above code to confirm the SSH connection. I've been attempting to comprehend the Fabric documentation yet it's a little past me so I'm trusting somebody can reveal to me how to include the password to validate the connection (and furthermore confirm any orders using sudo).

Thanks in advance:)

1 Answer

0 votes
by (26.4k points)

Alright, it would appear that you can pass choices to the Connection constructor that will be given to SSHClient.connect 

c = fabric.Connection("", port=22, user="pi", connect_kwargs={'password': 'raspberry'})

Note it's generally an impractical notion to store your passwords in plain text, particularly in code.

Have a look at these documentation, for more information

Looking for a good python tutorial course? Join the python certification course and get certified.

For more details, do check out the below video tutorial...

Related questions

0 votes
1 answer
asked Dec 22, 2020 in Python by laddulakshana (16.4k points)
0 votes
1 answer
asked Jul 31, 2019 in AWS by yuvraj (19.1k points)
0 votes
2 answers
asked Oct 4, 2019 in Python by Tech4ever (20.3k points)
0 votes
1 answer

Browse Categories