Skip to main content
Share Your Experience: Take the 2024 Developer Survey
16 votes
Accepted

SSH passing your Public key to all the users on remote host

That looks crazy. But some constructive comments: Did you check for ssh-copy-id script, that is usually shipped with openssh? ...
Jakuje's user avatar
  • 316
10 votes
Accepted

Send commands over SSH to server

To answer your questions: Yes. Your code could be boiled down to: ...
Graipher's user avatar
  • 41k
8 votes
Accepted

Becoming a Perl bandit

This answer is going to talk about your style, and best practices. Some of it may be subjective. I'll go through the code line by line. use strict; use warnings; ...
simbabque's user avatar
  • 993
7 votes
Accepted

SFTP Ruby script for downloading files from server

One of the core elements your code is missing is object-orientation. Take advantage of Ruby's powerful object model. That alone will vastly improve what you have. What we're going to do is ...
Damien's user avatar
  • 335
6 votes

SSH passing your Public key to all the users on remote host

The conditions to create keys The condition on the directory seems a bit excessive here: ...
janos's user avatar
  • 111k
5 votes
Accepted

Finding all non-empty directories and their files on an SFTP server with Paramiko

There is nothing obviously wrong with your implementation that could explain a slow behaviour. The slowest part here being the use of listdir_attr, you might want ...
301_Moved_Permanently's user avatar
5 votes

Remotely collect server data using Net::OpenSSH

Looks good to me. Kudos for the "... or die" idiom. More informative output would be "unable to run df on $s" or "unable to run svmon on $s". You don't have to do ...
J_H's user avatar
  • 27.5k
5 votes
Accepted

Python script to execute a command using Paramiko SSH

All your imports should be below eachother like this: import sys import paramiko import getpass I think using classes is a bit too much for this, but you should ...
Ludisposed's user avatar
  • 11.5k
5 votes

Running SSH commands on multiple servers

Looks like Fabric is what you need. Fabric is a pretty simple deploy tool (comparing to Ansible/Puppet/etc), that lets you execute simple shell commands over SSH (Paramiko inside). Features you ...
A. Haaji's user avatar
  • 191
4 votes

Running SSH commands on multiple servers

Overall, the code is not complicated and can be understood. I would though focus on improving variable names and modularity: remember that the code is much more often read than written - try to name ...
alecxe's user avatar
  • 17.3k
4 votes
Accepted

Fetching system info using python

I would start by making your ip_list easier to understand. You could write a class for this, but using a collectins.namedtuple ...
Graipher's user avatar
  • 41k
4 votes

Finding all non-empty directories and their files on an SFTP server with Paramiko

You miss imports for your function (I believe it is somewhere in your code, but not in the posted snippet): from collections import defaultdict import os Creation ...
Jakuje's user avatar
  • 316
4 votes

Creating remote directories in a bash script via ssh (with error trapping)

Running ssh in a loop is not efficient. Since the script is not interactive, you could pass the entire script to a remote Bash process on ...
janos's user avatar
  • 111k
4 votes

Bash script using SSH to sum disk usage on NetApp

I have no idea of what you are trying to achieve, but still here we go. Less indentation is better than more indentation. Compare ...
vnp's user avatar
  • 56.5k
3 votes

Creating remote directories in a bash script via ssh (with error trapping)

Succinct: #!/bin/bash -e ssh remotehost mkdir -p /var/www/{files,photos,info} Failure to create any directory will give non-zero exit for ssh, which causes the ...
Oh My Goodness's user avatar
3 votes
Accepted

Sending an uptime to a remote server through SSH with the method pxssh

It sounds like the problem is not the code but how to package it up in a such a way that only functions that you want to call get called when you want to call them. A part of the solution is as you ...
War's user avatar
  • 156
3 votes
Accepted

Squire for your recursive SSH adventures

I think that ssh "$@"; exit $?; can be simply exec ssh "$@". That's objectively better, because now if <...
Toby Speight's user avatar
  • 75.7k
3 votes

Ruby - Sending commands to multiple servers using Net::SSH

I think this is interesting code. I admit I haven't dug much into Ruby's Net::SSH library, so I bet you've learned some things about it in writing this code. It sounds to me like your biggest concern ...
Howard Miller's user avatar
3 votes
Accepted

Python File Explorer / RSync Terminal User Interface

The main problem with this code is that it's very hard to comprehend. This review will focus on this issue exclusively, not on the logic of the code itself. Once your code is more clean and 'pythonic' ...
QuasiStellar's user avatar
  • 2,239
2 votes
Accepted

Moving WordPress database and files to new host

Make input validation more user-friendly You ask to enter host, user and port, and if one of them is empty you exit. If I entered a host and a user and accidentally pressed enter for port (empty), I ...
janos's user avatar
  • 111k
2 votes
Accepted

Executing remote command using expect from C++

Consider using raw literals Your expect_template is a prime candidate to be written as a raw string literal: ...
Jerry Coffin's user avatar
  • 33.6k
2 votes
Accepted

Basic automation of SSH tasks in a restricted environment

./launcher I'm no Bash person, so I have little to say about your launcher except where you call Python: ...
zondo's user avatar
  • 3,797
2 votes

Python script to execute a command using Paramiko SSH

First thing I would do is to refactor your code and redesign it following the functional or OOP concepts. As it is right now, your code is shaped according to an old school of doing things (sequential ...
Billal Begueradj's user avatar
2 votes

throwcatch: Super easy, SFTP-based backup tool

Exit code When the --remove parameter is present, the script always exits with 1, regardless of successful removal or failure. This seems inappropriate, because ...
janos's user avatar
  • 111k
2 votes
Accepted

BFA protected phpmyadmin

One potential security issue: what if ${drt} is not set before this is run? A safety check will be very useful. As for your wider issue, rather than having to ...
Joe C's user avatar
  • 1,085
2 votes
Accepted

Python rsync to copy the logs from multiple remote servers

Review Constants should be UPPER_SNAKE_CASE More (and better) functions! Lot of this code is in the global namespace, which is bad (not maintainable) Why is <...
Ludisposed's user avatar
  • 11.5k
2 votes

Python functions to fetch spreadsheets through SFTP and from Dropbox

From looking at the code, some things seem off: valid_extensions is defined, but not used connect_to_sftp(), ...
maxb's user avatar
  • 1,522
2 votes
Accepted

Log Retrieval Script

handle more possibilities Anything touching the file system can fail. mkdir You could have permission problems or something else. Do mkdir foo || exit 3. Feel ...
chicks's user avatar
  • 2,863
2 votes
Accepted

Syncing GitHub repositories local, remote and forks

There's no need to reinstate the initial value of IFS because there's nowhere for the new value to propogate. When your script exits, the new value just ceases to ...
Oh My Goodness's user avatar
2 votes

Retrieve Logs from Multiple Containers on Remote Server

Error messages should be redirected to stream 2 (standard error): ...
Toby Speight's user avatar
  • 75.7k

Only top scored, non community-wiki answers of a minimum length are eligible