ftp/ssh/shell/filezilla Flashcards

1
Q

ftp: to log into ftp connection using python, type

A

import ftplib

ftp = ftplib.FTP(‘ftp.example.com’,’usename@example.com’,’password’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

ftp: To check the type of server

A

go to the site in chrome, open the network tab, and in the response header it will say

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

ftp: If you want to check the operating system you can use

A

http://toolbar.netcraft.com/site_report/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

ssh: SSH allows

A

remote shell access and as slow encrypted file transfer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

ssh: many hosting providers do not provide ssh access because

A

there have been cases of users of a shared server accessing each others files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

ftp: ftp is mainly used for

A

making files publicly available through a browser, or transfering files to and from a server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

ssh: ssh stands for

A

secured shell

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

ftp: ftp cannot

A

run shell commands

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

ftp: To upload an entire directory recursively, type

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

ftp: To return your current directory, type

A

ftp.pwd()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

ssh: To end an ssh connection, type

A

return
return
~.
note: returns are necessary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

pythonanywhere: To ssh into pythonanywhere, type

A

ssh username@ssh.pythonanywhere.com

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

ssh: To copy a local file into a server through ssh, type

A

scp /path/file.py username@host.com:/path/folder

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

ssh: To copy a local file into pythonanywhere through ssh, type

A

scp ssh.py bigintro@ssh.pythonanywhere.com:/home/bigintro

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

ssh: To copy a file from a remote server to local, type

A

scp username@host.com:/path/folder /path/file.py

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

ssh: To copy entire folders, type

A

scp -r /path/folder username@host.com:/path/folder

note: cannot create to folders by appending them to the path of the destination

17
Q

ssh: to set the name of the file that gets sent through scp, type

A

scp /path/file.py username@host.com:/path/folder/chosen_file_name.py

18
Q

ssh: To ssh in python use

A

paramiko

19
Q

ssh: To download something from unix command line, use

A

wget

20
Q

html: To create a self signed ssl certificated on a server

A
go to home/username
mkdir certificates
cd certificates
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem
Generating a 1024 bit RSA private key
21
Q

ipython: To locate .ipython, type

A

ipython locate

22
Q

pythonanywhere: To send my app to pythonanywhere from the shell

A

set up environment variables
collectstatic locally
rsync -r –delete-after project_folder/ bigintro@ssh.pythonanywhere.com:/home/bigintro/project_folder/
makemigrations and migrate in the app

23
Q

ssh: To sync a local folder with a remote one while deleting extraneous files, type

A

rsync -r –delete-after project_folder/ bigintro@ssh.pythonanywhere.com:/home/bigintro/project_folder/

note: If there is no trailing slash, you will pass in the entire directory, and if there is you will pass in the contents
note: make sure remote app doesn’t use sqlite or it will be overwritten

24
Q

git: To download a directory from github, type

A

git clone https://repo.git

25
Q

filezilla: If you are connectting via sftp instead of ftp, you must

A

precede the host (ip of server) with sftp://

26
Q

filezilla: To transfer files to server or download

A

navigate to the file in your local file viewer and simply drag it into the folder you want, and to download, drag the file from the remote viewer into the local.