SFTP

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search

SFTP is SSH File Transfer Protocol, however, they don't call it SSHFTP so some assume it merely is Secure File Transfer Protocol.

SFTP relaces FTPS (how confusing is that?) which was an early attempt to make FTP more secure. Neither "replace" FTP as there are situations where it is not necessary to encrypt a file transfer. Any source that calls either a replacement for FTP is in error.

SFTP (SSH File Transfer Protocol) is a secure file transfer protocol. It runs over the SSH protocol. It supports the full security and authentication functionality of SSH. The SFTP protocol runs over the SSH protocol as a subsystem.

SFTP protects against password sniffing and man-in-the-middle attacks, and protects the integrity of the data using encryption and cryptographic hash functions. Both the host and server require authentication.

The sftp command in Linux is a client program for SFTP. The sftp command line interface was designed to be similar to the ftp command. The sftp command is typically part of the OpenSSH package.

On Linux, SFTP is often used as a command-line utility that supports both interactive and automated file transfers. Public key authentication can be used to fully automate logins for automated file transfers.

sftp cli example 1:

sftp nicolep@192.168.1.10:/home/camerauser/pic.jpg /home/nicolep/Pictures

To initiate an SFTP connection, use sftp command with a username and remote host’s name or IP. Default TCP port 22 should be open for this to work or else explicitly specify the port using -oPort flag.

SSHFS

You can mount a remote filesystem locally via SFTP using SSHFS.

SSHFS itself is a file system in user space (FUSE) that uses the SSH File Transfer Protocol (SFTP) to mount a remote file system. The sshfs command is a client tool for using SSHFS to mount a remote file system from another server locally on your machine.

To install on a Ubuntu/Mint/Debian system

sudo apt-get install sshfs

Because SSHFS uses SFTP , all transmitted data between the server and the client must be encrypted and decrypted. This results with a slightly degraded performance compared to NFS, and higher CPU usage on the client and server.

To mount a remote directory the SSH user needs to be able to access it. The SSHFS mount command takes the following form:

sshfs [user@]host:[remote_directory] mountpoint [options]

An example:

sshfs nicolep@server.com:/home/goodfiles /home/nicolep -C -p 2022

The -C enables compression.

You can try to specify everything on the command line or you can utlize the ssh configuration file. OpenSSH client-side configuration file is named config, and it is stored in the .ssh directory under the user’s home directory.

vi ~/.ssh/config