09.11.2012 Views

Mac OS X Server Command-Line Administration - Apple

Mac OS X Server Command-Line Administration - Apple

Mac OS X Server Command-Line Administration - Apple

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Sending <strong>Command</strong>s to a Remote <strong>Server</strong><br />

Secure Shell (SSH) lets you send secure, encrypted commands to a server over the<br />

network. You can use the ssh command in Terminal to open a command-line<br />

connection to a remote server. While the connection is open, commands you type are<br />

performed on the remote server.<br />

Note: You can use any application that supports SSH to connect to <strong>Mac</strong> <strong>OS</strong> X <strong>Server</strong>.<br />

To open a connection to a remote server:<br />

1 Open Terminal.<br />

2 Type the following command to log in to the remote server:<br />

ssh -l username server<br />

where username is the name of an administrator user on the remote server and<br />

server is the name or IP address of the server.<br />

Example: ssh -l admin 10.0.1.2<br />

3 If this is the first time you’ve connected to the server, you’re prompted to continue<br />

connecting after the remote computer’s RSA fingerprint is displayed. Type yes and<br />

press Return.<br />

4 When prompted, type the user’s password (the user’s password on the remote server)<br />

and press Return.<br />

The command prompt changes to show that you’re now connected to the remote<br />

server. In the case of the above example, the prompt might look like<br />

[10.0.1.2:~] admin$<br />

5 To send a command to the remote server, type the command and press Return.<br />

To close a remote connection<br />

m Type logout and press Return.<br />

Sending a Single <strong>Command</strong><br />

You can authenticate and send a command using a single typed line by appending the<br />

command you want to execute to the basic ssh command.<br />

For example, to delete a file you could type<br />

$ ssh -l admin server1.company.com rm /Users/admin/Documents/report<br />

or<br />

$ ssh -l admin@server1.company.com "rm /Users/admin/Documents/report"<br />

You’re prompted for the user’s password.<br />

16 Chapter 1 Typing <strong>Command</strong>s

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!