Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions 09-check-user-and-perform.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/opt/anaconda3/bin/python

## Modules
import getpass

user = getpass.getuser()

if user == "ahamedm" :
print("I am the admin\nI can install software\nI can create user")
else:
print("I dont have enough permission")
25 changes: 25 additions & 0 deletions 09-ssh-remote-server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/opt/anaconda3/bin/python

## Modules
import getpass
import paramiko

server = input("Enter the server name : ")
user = input("Enter the user name : ")
passwd = getpass.getpass()

ssh = paramiko.SSHClient()

ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

## Connect to the server
try:
ssh.connect(hostname=server, username=user, password=passwd)
except:
print("[!] Cannot connect to the SSH Server")
exit()

## Executing the commands
stdin, stdout, stderr = ssh.exec_command('ls -l')

print(stdout.read().decode())