Murphy Mac » Posts in 'Terminal' category

Secure Browsing With An SSH Proxy

Your Mac makes it easy to browse the web using a secure connection to a proxy. There are a couple of reasons you might want to do something like this:

  • You’re working at a company that has blocked access to certain sites
  • You’re using a wifi hot-spot and you think the provider might be snooping
  • You don’t want your work IT guys watching your traffic.
  • You’re having unresolvable problems connecting to Internet resources from your current location.

Lifehacker posted complete instructions on how to configure Firefox to use an SSH session for all its activity. There are only two steps. One is to change a preference in Firefox. The other is to initiate the SSH session using the N and D options - which together listen for a specified port on your machine and send the corresponding traffic to the proxy - which is the machine at the other end of your SSH connection.

SSH ProxyThe proxy (maybe a machine at your house or your hosting provider) actually retrieves the web pages you want using its Internet connection, then sends them to you over the encrypted channel. The provider at your location can’t see what you’re browsing, they just see that you’re connected to a remote computer using SSH.

If you’ve got a Mac at home that you can leave on you can use it for this purpose. But it’s not ideal. Most residential ISPs don’t deliver good upstream speed. Everything you want to see will first be downloaded and then uploaded by the machine at your house.

Murphy’s hosting provider allows SSH access. That’s a valuable thing in a host for many reasons - and it allows you to use their machine(s) as your proxy. You’ll probably get much better bandwidth going that route. Nice pun.

In the screencast Murphy uses a domain name instead of the external IP of his home machine. This is accomplished through an entry in the hosts file. He also mentions using ssh, securely, without passwords. There’s a screencast on that too.

Sidenote: Murphy started creating this screencast at Panera and realized the G5 at home (which can accept an SSH connection) was asleep. But there’s a Windows machine that’s always on in the basement - and it can be contacted to wake up other machines on the home network. You could do something like this with Mail rules - or just use Chicken of the VNC.

Share/Save/Bookmark

Watch Now | Permalink

Split Files Into Smaller Files

split filesSometimes a file is just a little too big for the media you want to store it on or the pipe you want to squeeze it though. The split command is here to help. It’s fast, it’s easy - and it’s already on your Mac.

In the screencast Murphy splits a thirty-something megabyte video into 9mb chunks - so he can back them up on his gmail account. (I’m expecting a lot of “Wouldn’t it be easier to…” on this one.) Keep in mind this is not a video splitter. The pieces aren’t viewable until you reassemble them. But you can use split on all kinds of files, even your zip archives.

We’ll be using the cat command for reconstituting our original file. We’ve seen plenty of cat in previous screencasts, but we’ve never used it quite like this.

Also in the screencast: Murphy demonstrates that Folder Actions work in a Terminal session. He’ll copy the pieces from a split file to an action-enabled folder - and the pieces will be automatically mailed to his Gmail account! This post is action-packed.

Maybe you want to break up some super-jumbo files for dvd storage. Take a look at this if you’re planning on creating chunks over 2gb.

The syntax Murphy uses in the screencast for reassembly is the most straight-forward he saw anywhere on the web. If you look around a little you can probably find scripts that do the same thing. Or check out Murphy’s post on making a shell script, maybe you can make your own.


Share/Save/Bookmark

Watch Now | Permalink

scp: Secure Copy

Copying files from your Mac to another Mac or a Linux box is easy with scp - also known as secure copy. Mention ftp to anyone and the first thing they’ll tell you is that is sends your password in the clear.

scp-secure-copyA common complaint about the Mac is that it doesn’t have an ftp application. That’s not entirely true - there’s an ftp client you can access in Terminal. Still, it’s probably not what some users are looking for. You might want to skip ftp and take a look at scp, which transmits over an encrypted channel. Murphy uses scp to upload content to his Bluehost account, and has never had a need for ftp. If you want this kind of functionality make sure your host supports it.

You can use scp to copy entire folders, single files, or wildcard specified selections. You can upload files to the remote machine, or copy files down. You could copy a zip file up and then unpack it over ssh with zip.

In the screencast Murphy connects to a Linux machine, but the steps would be exactly the same if he were copying to another Mac. He’ll also show how to move a Terminal task to the background with bg, so other commands can be entered. This is especially useful when connected via ssh to a remote machine. You can kick off additional tasks without opening another ssh session or waiting for the current task to finish.

Throughout the screencast Murphy has to enter his password. That can get old really fast. See this post for a screencast about using keys instead of entering passwords.

The screencast assumes you’ve got some familiarity with getting around in the Terminal. If you don’t, check out Navigating the Terminal. It includes a warning screencast - tools like scp will overwrite files without warning. So be careful where you copy to.

Finally, Murphy refers to the remote machine by its ip address throughout the screencast. You can use domain names to use scp with computers on the Internet. You can use names on your own network too. See these two posts if you’re having trouble using names on your network:

The Hosts File
Netinfo Manager

Share/Save/Bookmark

Watch Now | Permalink

mkdir: Create Folders Quickly

mkdirThe Terminal is incredibly efficient when you need to make a few folders at once. You could come up with something in AppleScript or maybe Automator - but the Terminal makes it really easy.

By now you might know that Murphy always has a tiny Terminal window open. It’s great for zapping files to the web host or checking a calendar or even just restarting the Dock. As long as it’s open you can use it to create some folders too.

The screencast covers making multiple folders at once, spaces in folder names, and creating an entire hierarchy with a single command. The last part comes from a tip on Lifehacker.

In the screencast Murphy uses backslashes to escape spaces in a folder name. You could also use quotes around the name.

If you create the same groupings of folders all the time you could assign the command to an alias or create a shell script.

Share/Save/Bookmark

Watch Now | Permalink

When Force Quit Doesn’t Work - There’s Still Kill

force quit and killForce Quit almost always works when an application gets confused and stops responding. But there might be an extremely rare occasion when Force Quit doesn’t do its job.

At that point you can use the kill command followed by the PID number of the locked-up application. Where do you find the PID? Use the top command. PID? Top? What are you talking about Murphy? It’s all in the extremely short screencast, so take a look.

Let’s also mention that Murphy doesn’t use Force Quit all that often. This sounds like the commercial - but the Mac just works. Maybe once every couple of weeks. Compare that to Murphy’s Windows machine, where Task Manager is in the Startup Items.

If there’s one thing that Microsoft really needs to fix it’s the way Windows handles non-responding applications. The little pop-up comes up asking if you really want to end the program. You say end now and it pops up again. And again. AARGH! Maybe it’s better in Vista? Let us know in the comments.

We’ll revisit the “top” command soon. But for now the screencast will tell you what you need to know about killing applications.

Share/Save/Bookmark

Watch Now | Permalink