Difference between revisions of "SFTP"

From Tootsville Wiki-Wiki
Jump to: navigation, search
(→‎Accessing the Host)
(→‎Accessing from MacOS)
 
Line 67: Line 67:
 
== Accessing from MacOS ==
 
== Accessing from MacOS ==
  
−
Needed: instructions on creating a key and exporting as a public key
+
As with most Internetty things on MacOS, the system ships with all the tools you need, but only in '''Terminal''' mode.
  
−
Connecting from Finder …
+
To create a public key, follow this guide: https://coolestguidesontheplanet.com/create-a-ssh-private-and-public-key-in-osx-10-11/ up to the point at which you make the file <tt>~/.ssh/id_rsa.pub</tt>
 +
 
 +
Then, copy that file <tt>cp ~/.ssh/id_rsa.pub ~/Documents/</tt><i>yourname</i><tt>.pub</tt>
 +
 
 +
… and send that public key to whoever is setting up your access to the host.
 +
 
 +
The <tt>sftp</tt> command from Terminal is available … Since MacOS is basically a BSD system, this should be mostly correct: https://www.freebsd.org/cgi/man.cgi?query=sftp&sektion=1 but <tt>man sftp</tt> from within '''Terminal''' would be up-to-date for your own system.
 +
 
 +
Need a Mac user to vet and document a graphical SFTP program; here is a discussion thread with some mentioned:
 +
https://apple.stackexchange.com/questions/25661/whats-a-good-graphical-sftp-utility-for-os-x
  
 
== Accessing from Windows ==
 
== Accessing from Windows ==

Latest revision as of 10:55, 19 October 2016

SFTP stands for Secure File Transfer Protocol.

It is not the same as FTPS (another secure way to transfer files) or FTP (an insecure way to transfer files).

Builder Toots use SFTP to access certain server files.

Accessing from Linux[edit]

Getting Access Permissions[edit]

You'll need to generate an SFTP public key and be added to the permissions for the host beforehand.

You can use the program “Passwords and Keys” (Seahorse) to create this file. (If it doesn't appear in your applications screen in Activities Overview, install it with Gnome Software. Search for “Seahorse.”)

Open “Passwords and Keys.” In the left sidebar, look under “Secure Shell” for “OpenSSH Keys.”

Seahorse OpenSSH Keys.png

Creating a new key[edit]

If you do not have any keys listed yet, create a new key.

Click the blue “+” sign.

Seahorse Create OpenSSH.png

Select “Secure Shell Key” and click “Continue.”

Seahorse Create OpenSSH Step2.png

Enter your e-mail address. You can adjust the Advanced settings, but RSA 2048 or higher is recommended.

Click on Just Create Key.

You may add a protective passphrase if you would like to, or, just hit Return/Enter to skip it.

Exporting the Public Key file[edit]

Now, click on the OpenSSH key to highlight it. From the menu bar, pick File → Export….

Choose a location to save the “.pub” file. You might want to rename it to your own name — for example, instead of “id-rsa.pub” you might instead save it as “john-doe.pub” or so.

Send this public key file via any method you like (eg: e-mail) to the person who is setting up your SFTP access.

Connecting[edit]

In Gnome Files (aka Nautilus):

Open Files.

In the lower-left corner, look for the “Other Locations” label. (You may have to scroll down in the left sidebar.)

Nautilus Other Locations.png

Click “Other Locations,” then enter the SFTP address. The form will usually be:

     sftp://YOUR-USERNAME@REMOTE-HOSTNAME.tootsville.adventuring.click/SOME/FOLDER/PATH/

Nautilus SFTP Location.png

Click “Connect.”

If your private key is protected by a passphrase, you may have to enter it now.

The first time you connect, you may see a confirmation message about the fingerprint of the remote server. This is to make sure that you're not connecting to a machine at the other end that's just pretending to be the server you expected. Check it against the value you were given before accepting it.

Accessing from MacOS[edit]

As with most Internetty things on MacOS, the system ships with all the tools you need, but only in Terminal mode.

To create a public key, follow this guide: https://coolestguidesontheplanet.com/create-a-ssh-private-and-public-key-in-osx-10-11/ up to the point at which you make the file ~/.ssh/id_rsa.pub

Then, copy that file cp ~/.ssh/id_rsa.pub ~/Documents/yourname.pub

… and send that public key to whoever is setting up your access to the host.

The sftp command from Terminal is available … Since MacOS is basically a BSD system, this should be mostly correct: https://www.freebsd.org/cgi/man.cgi?query=sftp&sektion=1 but man sftp from within Terminal would be up-to-date for your own system.

Need a Mac user to vet and document a graphical SFTP program; here is a discussion thread with some mentioned: https://apple.stackexchange.com/questions/25661/whats-a-good-graphical-sftp-utility-for-os-x

Accessing from Windows[edit]

Windows does not yet have built-in SSH or SFTP abilities, but you can download the free program Putty to help.

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

You probably want to download the MSI file: scroll down and look for something in the green box like:

      A Windows MSI installer package for everything except PuTTYtel
      Installer: putty-0.67-installer.msi (or by FTP) (signature)

After downloading, double-click the MSI file and follow its on-screen instructions as usual.

Create a public/private key[edit]

Launch the program PuttyGen

PuttyGen Interface.png

Make sure that you selected at the bottom panel either SSH-2 RSA or SSH-2 DSA and that the number of bits is at least 2048. Then, click Generate.

Follow the directions (wiggle the mouse over the blank area) to create the key.

Change to Key comment to your e-mail address. (The default will be some nonsense like “rsa-key-20161013.”)

Click “Save Public Key” and choose a location. You'll want to name the file something like your name “.pub” — eg “john-doe.pub”.

Send that key file to the person who's setting up your access. That file can be published — by itself (without the private, secret key on your computer) it's useless.

Accessing the Host[edit]

Open a Terminal (aka “Command Prompt”) window. (You can do this by holding the “super” — or Windows logo — key, and press “R,” then type “CMD” and Enter)

Use the CD command to go to the local folder that you want to transfer files to/from. You can type “CD ” (c, d, space) and then drag a folder icon into the Terminal, and then press Enter.

    CD "C:/Users/YOURNAME_01/Documents/Tootsville/Stuff"

Connect to the remote server by typing the location of the PSFTP.exe program — you can also drag the PSFTP icon into the window to fill it in for you. Then, type “open ”, followed by everything after “sftp://” in the address to which you want to connect. For example, to connect to “sftp://yourname@hostname.tootsville.adventuring.click” you might type:

     C:/> "C:/Program Files (x86)/Putty/bin/psftp.exe" 
     PSFTP> open yourname@hostname.tootsville.adventuring.click

You can then enter PSFTP Commands to interact with the remote server.

Typically, you will use:

  • “cd” to change directories,
  • “pwd” (Print Working Directory) to show the current directory's name,
  • “ls” or “dir” to list files and directories,
  • “get” or “mget” or “reget” to fetch a remote file to your system,
  • “pet” or “mput” or “reput” to send a local file to the remote system.

Check the Putty manual for command information.

Alternative: FileZilla[edit]

You can use Putty's PAgent program together with another program, FileZilla, to access the host with a graphical program (instead of the terminal-mode program PSFTP). You still do need Putty to be installed with PuttyGen and PAgent to use FileZilla for SFTP.

Watch out! Make sure you understand whether you want to install additional “special offers” of bundled software during the installation process. We recommend choosing NO on any “offers” that appear!

Screenshot from 2016-10-13 14-37-05.png

After installation, follow these instructions. https://wiki.filezilla-project.org/Howto

Basically: Start PAgent, and it will disappear into your “notification area.” Then start FileZilla.

On the menu, pick File → Site Manager

Click New Site on the left and enter a name for this host.

On the right-hand side, be sure to pick SFTP under Protocol: and enter the host name and your user name.

FileZilla Host Setup.png