ftp/ssh/shell/filezilla Flashcards
ftp: to log into ftp connection using python, type
import ftplib
ftp = ftplib.FTP(‘ftp.example.com’,’usename@example.com’,’password’)
ftp: To check the type of server
go to the site in chrome, open the network tab, and in the response header it will say
ftp: If you want to check the operating system you can use
http://toolbar.netcraft.com/site_report/
ssh: SSH allows
remote shell access and as slow encrypted file transfer
ssh: many hosting providers do not provide ssh access because
there have been cases of users of a shared server accessing each others files
ftp: ftp is mainly used for
making files publicly available through a browser, or transfering files to and from a server
ssh: ssh stands for
secured shell
ftp: ftp cannot
run shell commands
ftp: To upload an entire directory recursively, type
import ftplib
import os
ftp = ftplib.FTP(‘ftp.example.com’,’usename@example.com’,’password’)
my_file_path = r’/users/path/’
def upload_this(path):
files = os.listdir(path)
os.chdir(path)
for f in files:
if os.path.isfile(path + r’/{}’.format(f)):
fh = open(f, ‘rb’)
ftp.storbinary(‘STOR %s’ % f, fh)
fh.close()
elif os.path.isdir(path + r’/{}’.format(f)):
ftp.mkd(f)
ftp.cwd(f)
upload_this(path + r’/{}’.format(f))
ftp.cwd(‘..’)
os.chdir(‘..’)
upload_this(my_file_path)
ftp: To return your current directory, type
ftp.pwd()
ssh: To end an ssh connection, type
return
return
~.
note: returns are necessary
pythonanywhere: To ssh into pythonanywhere, type
ssh username@ssh.pythonanywhere.com
ssh: To copy a local file into a server through ssh, type
scp /path/file.py username@host.com:/path/folder
ssh: To copy a local file into pythonanywhere through ssh, type
scp ssh.py bigintro@ssh.pythonanywhere.com:/home/bigintro
ssh: To copy a file from a remote server to local, type
scp username@host.com:/path/folder /path/file.py