Accessing Remote Files Easily and Securely
The secure shell, ssh, and its companion, scp, are tools that I use more or less on a daily basis. Being able to move files between machines without having to setup SAMBA or NFS is very handy when working with multiple systems. All that you need is to enable the secure shell daemon - sshd.
Before we go into the details of the sshfs, let's run through a quick re-cap of ssh. The secure shell daemon runs on port 22 by default. It makes it possible to run an encrypted shell session. With the -Y flag, you can even run X11-forwarding, allowing you to run X11, i.e. graphical, programs on the remote machine and displaying the windows on the terminal that you are sitting at.
You can configure sshd through the /etc/ssh/sshd_config file (that is the location on my Kubuntu machine). Here, you can disable root access, older protocols, X11 forwarding, etc. The notion is that the more limits you put on the remote access, the more secure your system is from potential attacks. You might also want to tune your hosts.allow and hosts.deny files if you plan to expose sshd to the Internet. There are many guides on hardening servers and ssh, so I will not go into details.
To get things up and running, what you need to do is to install sshd. In Ubuntu, that means the openssh-server package. For external access, you also need to enable port forwarding of port 22 in your router/firewall and find your external IP. Now, you should be able to log onto your machine using your normal user credentials.
$ ssh email@example.com firstname.lastname@example.org's password:
Having entered the password, you should now have full access to the remote system.
The handy scp command, secure copy, works in much the same way. To copy the file test.txt to user's remote home directory, simply enter:
$ scp test.txt email@example.com:
As before, you will be prompted for a password. You can copy the other way around as well. The command below demonstrates how to copy a file with an absolute path, i.e. not in the home directory of user, to your local machine.
$ scp firstname.lastname@example.org:/var/log/messages remote-messages
These two commands means that you can browse the file system, and freely copy files between machines. What sshfs does is that it exposes this functionality as a file system that you can mount. Before we look into how, let's have a quick look at sshfs.
The sshfs is implemented using FUSE, and relies on the sftp part of ssh to access the remote computer. As a remote file access protocol, sshfs is not very good. For instance, multiple users writing to the same file at once can create havoc. The benefits are the inherit security and that it is easy to setup.
So, how to use it. Let's look at a very short demonstration.
$ sshfs email@example.com: remote-home $ ls remote-home Desktop Documents Downloads Music $ fusermount -u remote-home
The initial sshfs command mounts the user's home directory to remote-home. You can specify another path after the colon to mount any other part of the remote file system. Access is only restricted by user's access rights.
Using ls, or any other ordinary command, will work as if the remote home directory was mounted locally. All tools work. For instance, you can log onto your remote machine and build software using your locally installed setup of build tools.
To unmount the filesystem, the fusermount command from the FUSE utilities package is used.
To summarize, sshfs an easy setup remote file access tool. It needs to be used with care if multiple users are involved. It makes it dead easy to temporarily access remote file systems, as well as mounting file systems from virtual machines for easier access and monitoring, as well as for remote installation, compilation and debugging. All-in-all, one of the tools I always keep handy in my toolbox.
Johan Thelin is a consultant working with Qt, embedded and free
software. On-line, he is known as e8johan.
Practical Task Scheduling Deployment
July 20, 2016 12:00 pm CDT
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.Register Now!
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- SUSE LLC's SUSE Manager
- My +1 Sword of Productivity
- Tech Tip: Really Simple HTTP Server with Python
- Non-Linux FOSS: Caffeine!
- Managing Linux Using Puppet
- Google's SwiftShader Released
- Parsing an RSS News Feed with a Bash Script
- Doing for User Space What We Did for Kernel Space
- SuperTuxKart 0.9.2 Released
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide