(from relearn 2015)... SSHaring ============= (how do you pronounce it ?) sch-sch-scering ? sch-sharing haring? ess-ess ha-ring? *the sharing machine as a garden @}----LEAF fill it with cr*p and watch beautiful things grow ========================== server = 10.9.8.7 Upload (a) file(s) that you brought with you to the server. Having a local server can mean many things. It means we can share files with each other with the convenience of a "dropbox" but without uploading files to servers halfway around the world (with not just technical but also potentially legal, economic, and other social consequences ) -- just to let someone sitting next to us have a copy. The server is also a shared (proto) publication; more than just a temporary holding place, the collection of files is a first step to a collective act of writing -- so the gardening of the space (organising, (re)naming, moving files, may be as important as adding them in the first place).--->care A fundamental thing about file sharing, though, is also the care that goes with preparing the material. Naming the file, putting in the right folder or creating the folder if it's missing; they are not trivial things. *File Drop ---------- You can drag and drop files onto pages of the web browser at: http://10.9.8.7/. You can also put files in specific folders. If you want to later change their name or location, you can use ssh (see below). *(you can see your upload process in your console) *sharing machine as a library: bibliotecha ------------------------------------------------------- For sharing electronic books (pdf, epub, ...), there's a special folder called bibliotecha. Digital books placed here are visible through a web interface of a free software project [Calibre](http://calibre-ebook.com/). [Bibliotheca](http://bibliotecha.info/) is a framework to facilitate the local distribution of digital publications within a small community. To add a book in the bibliotecha, you need to do it via the command-line: calibredb add -a AUTHOR -t TITLE -TAGS --with-library /home/www-data/bibliotecha filena.me for example: calibredb add -a "Jan Masschelein and Maarten Simons" -t "In defence of the school" -T diseducation --with-library /home/www-data/bibliotecha Jan_Masschelein-Maarten_Simons-In_defence_of_the_school.pdf *ssh ---------- When you ssh to another machine, there are a number of commands to: * Look at the files + folders * Create new folders * Remove files & folders * Manage the *file permissions* that control access to your files in the shared space of the server To add a folder or move files around, you need to connect via ssh to the server... you can make new directories (mkdir new_dir) move files around the folders (mv files new_location) *Summary of File commands ------------------ pwd print working directory: Show the current folder you are *working* with ls list: show the current files in the *working directory* mkdir images make directory: make the directory called images (in the working directory) cd change directory: move to another directory when used by itself it jumps to your home folder cd images Attempts to enter a directory named *images* in the working directory, this is a relative path (as it does *not* start with a slash) it is considered relative to the working directory cd /home/www-data Change working directory to /home/www-data this is an *absolute path* (starts with a slash) touch *somefile* Pretend you just edited and saved this file, creating a new file if necessary cat *somefile* Dump the contents of a file to the screen to read| less *somefile* A pager: shows the contents of a file with the ability to scroll (using the arrow keys), press *q* to quitSSH can be used like ftp to move files to and from a server. It's more secure than ftp though as your password and the contents of the files transmitted are encrypted. * *scp ----------- ### scp With the terminal, try commands like the following (where *myfile* matches the name of a file on your machine, and *username* and *server* are your username and the address of the local server). *scp myfile username@server: Copies myfile to *your*ls home folder on the server. NB: The colon at the end is essential as this makes the address a file location. If you forget the ":", the scp program will copy the file to another file named "username@server" -- not at all what you wanted! *scp -r folder username@server:images Copies a folder (recursively --- meaning contents included) to a folder named "images" in you home folder on the server. Accesible also in the browser via: http://10.9.8.7/ , act responsibly ;) *scp -r folder username@server:/home/www-data/ Copies a folder (recursively --- meaning contents included) to an absolute path on the server (the root of the webserver). DOWNLOAD FILES FROM SERVER TO YOUR COMPUTER don't be on the server and scp username@10.9.8.7:path/to/file path/to/your/download/folder *Permissions -------------- When you *ls -l Shows ... -rw-rw-r-- 1 automatist www-data 0 Aug 20 08:42 hello This file is *owned* by automatist, belongs to the the "www-data" group, has 0 bytes (it's empty) and was created on August 20 at 08:42 in the morning ;) The owner and group have read & write access, others can just read the file. You see not only the names of files, but their permissions. Permissions determine what you can do with a file. There are three main things: r: read (see the file) w: write (change the file) x: execute (run the file as script, or for a directory -- to make new things inside of it) In addition, there are three sets of permissions for: u: the user (or origina "owner" of the file) g: the *group* of the file o: for *others* (everyone else) You can use the command *chmod* to change permissions as in: chmod g+rw hello Means allow the file's group to read & write the file named hello. The chown command allows you to change ownership of a file: chown automatist hello Make hello owned by automatist. chown can also be used to set the group: chown automatist:www-data hello I'm not sure I understand why groups are necessary? Can't a file just be owned by a single file be a single user? What is the advantage of setting a group owner? Does it give ownership of the file to all people in the group? There is no group owner, the above example sets the file to belong to user automatist and group www-data. Anyone in the www-data group can access it if the file has the group read permission (see the chmod example above) and write to it if it has the group write permission. *GUI ------------- Generally, anytime you have ssh access to a server, this means that you can use *sftp* (secure file transfer protocol) to send and receive files from that same server. *sftp* is built on top of the ssh protocol. There are different graphical programs that give convenient access to working with files on a remote server. The window manager gnome supports a "Connect to server" feature that directly allows sftp connections, just use the form: sftp://USERNAME@10.9.8.7 *Cyberduck ----------------- On Mac OSX and Windows, [cyberduck](https://cyberduck.io/) is free software that provides a very helpful graphical interface to drag and drop files to and from a remote server. You can also *edit* files with an editor on your local machine (the program automatically uploads changes when you save them). Installers for cyberduck are available on the local server: * http://10.9.8.7/software/CyberDuck-4.7.2.zip for Mac OS X 10.7 64 bit Intel * http://10.9.8.7/software/CyberDuck-4.7.2.zip for Mac OS 10.6 * http://10.9.8.7/software/CyberDuck-Installer-4.7.2.exe for Windows Filezilla is a nice alternative that works well in Linux systems too. +1 And a good code editor: * http://10.9.8.7/software/SublimeText2.0.2.dmg Mac OS X (freeware) * http://10.9.8.7/software/SublimeText2.0.2x64Setup.exe Windows (freeware) Note: Sublime text is not freeware, you are supposed to pay for the license. It will keep working if you don't, which is why it's confused with freeware. A better code editor that doesn't hurt your freedoms is Gedit. Comes with Linux systems running Gnome, and there are also Win/Mac versions: * http://10.9.8.7/software/gedit-3.2.6-3.dmg (mac) * http://10.9.8.7/software/gedit-setup-2.30.1-1.exe (win) There is also Atom, if Gedit is too simple and you miss the bells and whistles of Sublime Text: * http://10.9.8.7/software/atom-windows.zip * http://10.9.8.7/software/atom-mac.zip * http://10.9.8.7/software/atom-linux.deb (for Debian-based distros like Ubuntu, Mint, Crunchbang) * http://10.9.8.7/software/atom-linux.rpm (for RPM distros like Fedora) Another editor that is already intsalled on your system is vi *sshfs --------- Another option is to use *sshfs* to mount the server like it was a local hard drive or USB stick. In Debian you can: sudo apt-get install sshfs and then: mkdir mnt sshfs user@serveranme: mnt Will connect your home folder with the local (initially empty) folder named mnt. The great thing about *sshfs* is that it allows you to use any software (commandline or graphical) with files on the server as if they were on your local computer. * *Generating an ssh key ------------------------ To make it easier to login to the server, you might want to generate an ssh key. *ssh-keygen *(run this on your own machine, not while you're logged in the relearn server) Generates the ssh key. An ssh key has a *private* and a *public* part, the idea is that you never share the private part, and do share the public part -- and the software uses the fact that the two parts can be checked if they "fit" together. * *- can we leave the passphrase blank? *A: It is possible, but not safe. If someone gets access to your machine they can copy your private key and get full access to all your servers. With a passphrase you still have one layer of security. *- is it possible to edit the passphrase after i created a ssh-key? *Great question, I don't know :-( * *is it possible to delete a key? *Sure, the keys live in your ~/.ssh directory (id_rsa is your private key, id_rsa.pub is the public key) The command: *ssh-copy-id USERNAME@10.9.8.7 Will copy your public key to the server (it adds the contents of your "~/.ssh/id_rsa.pub" file to "~/.ssh/authorized_keys" on the server). If this works, then you should be able to login to the server without typing your login password. *Server name shortcut -------------------------- Sick of writing 10.9.8.7 all the time? Make a shortcut in your ~/.ssh/config file adding these lines: *Host relearn *Hostname 10.9.8.7 *User YOURUSERNAME Now, instead of ssh user@10.9.8.7, you can just type ssh relearn . Copy your SSH keys (see above) for a seamless, streamlined and refreshing command line experience(tm). Fantastic! *note: in case your system asks you to enter the password to connect with your private key, enter your passphrase, not your system-password, nor server-password. *Make friends with your ssh-agent! ------------------------------------ Sick of typing your passphrase every time you want to login or copy something? There is a nice tool running on your system called ssh-agent, which can keep track of your keys for you and remember them to skip the passphrase step while you're logged in. Try typing ssh-add and input your passphrase. Now try connecting or copying a file, and it should do it passwordlessly! (word of the day)