Python - SSH


SSH or Secure Socket Shell, is a network protocol that provides a secure way to access a remote computer. Secure Shell provides strong authentication and secure encrypted data communications between two computers connecting over an insecure network such as the Internet. SSH is widely used by network administrators for managing systems and applications remotely, allowing them to log in to another computer over a network, execute commands and move files from one computer to another.

AS cloud servers become more affordable, SSH is the most commonly used tool to perform various tasks on cloud server. We need it for &;minus

  • Setup a web server for a client's website
  • Deploy source code to a production server

In python SSH is implemented by using the python library called fabric. It can be used to issue commands remotely over SSH.


In the below example we connect to a host and issue the command to identify the host type. We capture the result in and display it as a formatted text.

from fabric import Connection
result = Connection('').run('uname -s')
msg = "Ran {.command!r} on {}, got stdout:\n{.stdout}"

When we run the above program, we get the following output −


This is a sample result which will depend on the server.

Useful Video Courses


Python Online Training

Most Popular

187 Lectures 17.5 hours

Malhar Lathkar


Python Essentials Online Training

55 Lectures 8 hours

Arnab Chakraborty


Learn Python Programming in 100 Easy Steps

136 Lectures 11 hours

In28Minutes Official


Python with Data Science

75 Lectures 13 hours

Eduonix Learning Solutions


Python 3 from scratch to become a developer in demand

70 Lectures 8.5 hours

Lets Kode It


Python Data Science basics with Numpy, Pandas and Matplotlib

63 Lectures 6 hours

Abhilash Nelson