SSH

Using SSHFS

Although it's relatively simple, I thought I'd write a brief article on the use of sshfs, because it's such a helpful tool. First, you'll need to have sshfs and fuse installed. You can get them here(sshfs) and here(fuse). The server (remote) side doesn't need anything but sshd (ssh server) installed. The beauty of the whole arrangement is that sshfs is really just a kind of wrapper around ssh/sftp, so the server doesn't even need to know about any permissions other than the standard ssh login. You can mount any path from the server that you have access to via ssh. Using sshfs from the command line is really easy. To mount a filesystem, you'll want to do so as your standard user (not root). Simply do:
sshfs user@host: <mountpoint>
and to unmount:
fusermount -u <mountpoint>

Passwordless SSH logins

To enable login to a remote machine by ssh without having to enter the password is a useful thing, and one I get asked about with some regularity. I'll describe two methods I use, one that uses ssh public keys with no passphrases, and the other using ssh-agent to store the passphrases of your keys.

To use ssh keys, you'll first need to have one. You can create this with the ssh-keygen utility like so:

ssh-keygen -t <algorithm> -b <bit size>

for example:

ssh-keygen -t rsa -b 4096

Quick SSH logins with ssh_config and aliases

This little hack was inspired by an ssh-to hack in the O'Reilly book "Linux Server Hacks," and originally posted on the O'Reilly site under the 'hacks' category.  As the title suggests, it sets up aliases for any host listed in your ~/.ssh/config file, which allows you to log into those hosts via ssh with any of the options specific for that host by just typing the host alias on the command line. 

SSH_CONFIG - Man Page

Section: File Formats (5)
Index
BSD mandoc
 

NAME

ssh_config - OpenSSH SSH client configuration files  

SYNOPSIS

~/.ssh/config
/etc/ssh/ssh_config  

DESCRIPTION

ssh(1) obtains configuration data from the following sources in the following order:

  1. command-line options
  2. user's configuration file (~/.ssh/config )
  3. system-wide

SSHFS - Man Page

Section: User Commands (1)
Updated: April 2008
Index  

NAME

SSHFS - filesystem client based on ssh  

SYNOPSIS


mounting

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

unmounting

fusermount -u mountpoint

DESCRIPTION

SSHFS (Secure SHell FileSystem) is a file system for Linux (and other operating systems with a FUSE implementation, such as Mac OS X or FreeBSD) capable of operating on files on a remote computer using just a secure shell login on the remote computer. On the local computer where the SSHFS is mounted, the implementation makes use of the FUSE (Filesystem in Userspace) kernel module. The practical effect of this is that the end user can seamlessly interact with remote files being securely served over SSH just as if they were local files on his/her computer. On the remote computer the SFTP subsystem of SSH is used.  

Search Engine Optimization