Chapter 22. SSH, FTP, VPN, and Web Sharing

Chia sẻ: Tuan Nghia | Ngày: | Loại File: PDF | Số trang:6

lượt xem

Chapter 22. SSH, FTP, VPN, and Web Sharing

Mô tả tài liệu
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Chapter 22. SSH, FTP, VPN, and Web Sharing Email and Web surfing may be the most popular Internet activities, but the world's most gigantic network has many other uses.

Chủ đề:

Nội dung Text: Chapter 22. SSH, FTP, VPN, and Web Sharing

  1. Chapter 22. SSH, FTP, VPN, and Web Sharing Email and Web surfing may be the most popular Internet activities, but the world's most gigantic network has many other uses. The general idea is always the same, though: letting one computer reach out and touch another. Mac OS X offers a few features that embrace the more literal aspects of that notion. For example, you can turn your Mac into a Web server—an actual living Web site that anyone on the Internet can visit. This chapter also explores various advanced methods of manipulating your own Mac from the road, including remote access technologies like long-distance file sharing, FTP, SSH, and virtual private networking (VPN). Note: Most of these technologies are designed for full-time Internet connections (cable modem or DSL, for example). If you have a dial-up modem, these features work only when you're actually online. Still, they may occasionally be useful anyway. You could always get online, call up a friend and say, "Check out my Web site right now—here's the current IP address" or call someone back home to say, "I have to grab a file off my hard drive. Could you make the Mac on my desk go online?" 22.1. Web Sharing Using the Sharing pane of System Preferences, you can turn your Mac into a Web site (or server), accessible from the Web browsers of people on your office network, the Internet at large, or both. This feature assumes, of course, that you've already created some Web pages. For this purpose, you can use Web design programs (Macromedia Dreamweaver, for example, or the free Netscape Composer) or save documents out of TextEdit or Word as Web pages. Or you could let Mac OS X build Web pages for you using iPhoto or Image Capture. After you provide your friends and co-workers with your Mac's Website address, they can view your Web pages, graphics, and documents in their own Web browsers. And whenever you're online, your Web site is also available to any one on the Internet—but you don't have to pay a penny to a Web-hosting company. UP TO SPEED The IP Address Mess: Port Forwarding There are so many ways to connect to your Mac from another computer. You
  2. can use Web sharing, SSH, file sharing, screen sharing, and so on. They're easy to use—when you want to connect across your home or office network. When you want to connect from across the Internet, though, things get complicated fast. In that case, you need to know your home Mac's IP address. (It stands for Internet Protocol.) An IP address is always made up of four numbers separated by periods, like Every computer on earth that's directly connected to the Internet has its own unique IP address. Now, if you have only one Mac, and it's connected directly to your broadband modem, no big deal. You can find out its IP address by opening System Preferences, clicking Sharing, and clicking File Sharing. Unfortunately, your Mac at home probably isn't connected directly to the Internet. If you're like most people, it's connected to a router, or maybe an AirPort base station, so that several computers in your house can share the same Internet connection. In this setup, the router (or base station) has a unique IP address—not the Macs connected to it. (The router doles out private IP addresses to each computer in your house or office, usually beginning with 192 or 10. If you check your Mac's IP address in System Preferences, you'll find out only its private address—not the public one that's accessible from the Internet. To find out that information, you have to check your router or base station's configuration screen; check the router's manual for instructions.) All right: How are you supposed to connect to one particular Mac if it's connected to a router and doesn't have a true, "public" IP address? One solution is Back to My Mac, the remote-access feature described on Section It solves the behind-the-router problem for you, but it requires a .Mac account (Section 18.6). Otherwise, your only hope is to turn on a router feature called port forwarding. It makes the router pass signals intended for a specific port (Section 12.9) to one particular computer on the network. For example, you could direct all port-80 communications to the Mac doing Web serving, for example, and all 548 traffic to a Mac doing file sharing. The point is that, even with port forwarding, you still can't access two different machines using the same port. (For some services, including ssh and Timbuktu,
  3. you can work around this limitation by logging into the machine specified for port forwarding, and then from that machine, log into the others on the rest of the network.) Turning on port forwarding doesn't require a programming degree, but it's not simple by any means. For starters, the steps are different for every router model. Fortunately, you can find guided tutorials on the Web. You can use Google to search for your particular router model, or check, which offers free step-by-steps for hundreds of router models, including Apple's AirPort base stations. Even so, try to arrange the assistance of someone who knows networking. In this chapter, the term "your IP address" means your public IP address. If you have only one Mac, that's its IP address. If you have a router or wireless network, use that device's IP address—as passed along by port forwarding. Tip: Web sharing is also an easy and efficient way to share your Mac files with Windows PCs, either those on your office network or those on the Internet. No special software or translation is required, and posting your files on the Web page avoids all the usual complexities of sending files by email. Mac OS X's Web Sharing feature isn't some feeble junior version, either. Inside Mac OS X is Apache, one of the strongest and most popular Unix Web server programs— precisely the same one that drives 60 percent of the Internet's commercial Web sites. The bottom line: If you build it, they won't necessarily come. But you'll have the capacity to handle them if they do. 22.1.1. Firing Up Web Sharing Here's how you turn your Mac into a low-budget Web site: 1. Put the HTML documents, graphics, and files you want to publish into your Home Sites folder. Every account's Home folder has a Sites folder, and therefore the Mac can actually serve up lots of Web sites at once.
  4. Your Web site's home page, by the way, won't appear unless it's named index.html. (Apple has already put an index.html document into your Sites folder, just to give you the idea; feel free to replace it.) And the other files you put in Sites aren't accessible unless they're linked from your index.html page. 2. Open System Preferences; click Sharing. Turn on the Web Sharing checkbox (Figure 22-1). Figure 22-1. Use the Sharing System Preferences pane to make designated folders on your hard drive available to anyone on the Internet. Note that your Mac's IP address, shown here in underlined type, works only when people connect from across the local network. It probably won't work from across the Internet; see the box on the facing page. Also note the line below the Computer Name box. That's your Mac's Bonjour name, which is a bit friendlier than its IP address. You've just made the contents of your Sites folder available to anyone who connects to your Mac. 3. Send your network address to your friends and co-workers. People on your local office network can use your Mac's Bonjour name to connect. It appears at the top of the Sharing pane, as shown in Figure 22-1. For example, your colleagues can type http://office-mac.local/~chris into their Web browsers, where office-mac.local is your Mac's Bonjour name. If other people will be connecting from the Internet, you need to figure out your public IP address; as noted in the box on Section 22.1, that might be your router'sIP address, not your Mac's. Your Mac Web site's address might be, for example, (the number is your public IP address, and the name should be your short user name). Don't forget the final slash. Tell your friends to bookmark it so they won't have to remember all that. You've just put your Mac-based Web page on the Internet for all to see—that is, all who know your secret Web address. Maybe you'll want to distribute the address only to other people on your office network, using your tiny Web site as a distribution source for documents. Or maybe you'll want to go whole-hog, hosting an e-commerce Web site.(Read on.)
  5. 22.1.2. The Mac's Own Web Site The instructions above show you how to create a Web site in your Home Sites folder. In other words, they guide you through the process of creating a personal Web site. But if you have an Administrator account (Chapter 12), you can also put your Web pages into the main hard drive window's Library WebServer Documents folder. This is your Mac's main Web site folder, and its address is simply That is, it's just your public IP address, no user name needed. (Here again, if people will be connecting from across your office network rather than the Internet, they can replace the IP number with your Mac's Bonjour name.) Working with this primary Web site folder is only slightly different from the personal ones described above. Because you're now working inside an official Mac OS X system folder, you must mind your permissions (Section 13.2.2). Using the File Get Info command, you should set up the permissions of any folders and documents inside the Library WebServer Documents folder (an Images folder, for example) as described on Section 13.2.2. That way, you can ensure that your visitors are allowed to see your Web documents— and that random Internet hoodlums can't make any changes to them. 22.1.3. The Easiest Way to Distribute Files Here's a handy secret: If there isn't a document whose name is index.html in your Sites folder (or Library WebServer Documents folder), then visitors see, in their browsers, a handy list of the files that are in that folder (see Figure 22-2). This is a terrific convenience: It offers a quick, simple way for you to make a bunch of documents available for downloading. All your visitors have to do is click one of these file names. It downloads immediately, no matter what kind of computer your Web visitor is using. Tip: This has nothing to do with Web sharing, but it's kind of cool: You can see the contents of any folder on your Mac, just by typing its folder pathname into a Web browser's address bar. For example, to see what's in your Documents folder, type file:///Users/chris/Documents/ into Safari's address bar. You get a tidy list like the one
  6. shown in Figure 22-2, revealing what's in that folder. Click a link to open it. (If you're using Safari, you open a Finder window revealing the folder's contents instead.). Figure 22-2. Here's a great way to make files available to other people on your network or collaborators across the Internet. Just put your files into the Sites or Library WebServer Documents folder and make sure nothing is named index.html. The Parent Directory link takes you to the folder that contains this one—in this case, the Library WebServer Documents folder 22.1.4. More on Apache As noted above, Apache is the most popular Web-serving software in the world. As you can well imagine, it's powerful, reliable—and very technical. It is, after all, a Unix program. You can read more at any of these sources: • The Apache manual. To open it up, type http://localhost/manual/ into your browser's address bar. You won't get far reading this thing if you haven't spent some time at a technical college, but at least you'll know what you're up against. • Apache: The Definitive Guide. A book from O'Reilly. • Dozens of Mac OS X fans have posted specific Apachetweaking tips and tricks Note, too, that $350 will buy you a graphic front end for the various Apache settings, in the form of Tenon's iTools program (no relation to Apple's old iTools service). It still requires an understanding of the technical aspects of Web hosting, but at least it spares you from having to type out Unix commands to make your changes.
Đồng bộ tài khoản