I'd go with the subprocess module if using version 2.4+. If opting for the system-call path, Python offers an array of options such as os.system or the commands/subprocess modules. I gave Conch the once-over some time ago but it didn't appeal to me. This completes the setup of the private SSH key file on your own PC. Next, register it with the help of the ssh-add program: eval ' (ssh-agent -s)' ssh-add /.ssh/debianserver. I've used Paramiko with an eye towards replacing system calls but found myself drawn back to the wrapped commands due to their ease of use and immediate familiarity. Before registering the private SSH key file, open the terminal and verify that the SSH authentication agent is actually running. NOTE: its hard to beat rsync if you plan on transferring files via SSH, especially if the alternative is plain old scp. It probably goes without saying that SSH keys are almost always a better idea than passwords for this sort of stuff. You will need to setup SSH keys to enable password-less logins if you are wrapping system commands like "ssh", "scp" or "rsync." You can embed a password in a script using Paramiko or some other library, but you might find the lack of documentation frustrating, especially if you are not familiar with the basics of the SSH connection (eg - key exchanges, agents, etc). Edit: what you CAN do, is to use ssh to transfer files without already being connected, here is how: cat ssh cat >. use a Python library that provides SSH capabilities (eg - Paramiko or Twisted Conch)Įach approach has its own quirks. To TRANSFER files, you NEED scp, which stands for Secure Copy.There are a couple of different ways to approach the problem:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |