Guest User

Untitled

a guest
Feb 7th, 2018
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. #!/bin/sh
  2. # Define folders
  3. THEFOLDER='/mnt/my/folder'
  4. # List files
  5. THEFILES=`ls -p $THEFOLDER | grep -v "/"`
  6.  
  7. for file in $THEFILES
  8. do
  9. echo "Processing $file"
  10. lftp -u login,password -e "put $THEFOLDER/$file;quit" theftp/sub/folder
  11. done
  12.  
  13. pip install paramiko
  14.  
  15. import paramiko
  16.  
  17. username = 'my_username'
  18. password = 'my_password'
  19.  
  20. transport = paramiko.Transport((server, 22))
  21. transport.connect(username=username, password=password)
  22. sftp = paramiko.SFTPClient.from_transport(transport)
  23.  
  24. local_filename = '/tmp/filename'
  25. remote_filename = 'MyFiles/temp.txt'
  26.  
  27. sftp.put( local_filename, remote_filename )
  28.  
  29. USING PASSWORDS
  30.  
  31. FTP
  32.  
  33. To ftp files using name+passwd, include them in the URL like:
  34.  
  35. curl ftp://name:passwd@machine.domain:port/full/path/to/file
  36.  
  37. or specify them with the -u flag like
  38.  
  39. curl -u name:passwd ftp://machine.domain:port/full/path/to/file
  40.  
  41. FTPS
  42.  
  43. It is just like for FTP, but you may also want to specify and use
  44. SSL-specific options for certificates etc.
  45.  
  46. Note that using FTPS:// as prefix is the "implicit" way as described in the
  47. standards while the recommended "explicit" way is done by using FTP:// and
  48. the --ftp-ssl option.
  49.  
  50. SFTP / SCP
  51.  
  52. This is similar to FTP, but you can specify a private key to use instead of
  53. a password. Note that the private key may itself be protected by a password
  54. that is unrelated to the login password of the remote system. If you
  55. provide a private key file you must also provide a public key file.
  56.  
  57. #!/bin/bash
  58. expect -c "
  59. spawn sftp username@your_host
  60. expect "assword"
  61. send "your_password_herer"
  62. interact "
  63.  
  64. chmod +x sftp_autologin.sh
  65. ./sftp_autologin.sh
  66.  
  67. #!/bin/bash
  68. expect -c "
  69. spawn sftp myuser@myserver.com
  70. expect "assword"
  71. send "yourpasswordr"
  72. expect "sftp"
  73. send "get your_directory/yourfilename.txtr"
  74. expect "sftp"
  75. send "exitr"
  76. interact "
Add Comment
Please, Sign In to add comment