Simple ssh configuration
You work on a computer and you want to easily connect another distant(remote) computer without entering you password at each time. To do so, you must generate a private and a public key on your computer to be put on the .ssh directory on your home, using, for instance, the dsa protocol:
ssh-keygen -t dsa
Then, you have the two new files in the ssh directory
Add the public key id_dsa.pub to the list of keys in the .ssh/authorized_keys file of the distant computer (create the file if it does not exist). Now it should work for you!
In addition, you can simplify the connection by configuring your ssh. Edit the .ssh/config file on your computer and enter
StrictHostKeyChecking no Host RemoteComputer Hostname computer.domain.com User username Protocol 2 ForwardX11 yes
Protocol 2 is for ssh2 and ForwardX11 enables you to open a remote Xwindow. Typing
or (see Transferring files)
scp RemoteComputer:File .
is now sufficient to connect the distant computer without entering your password. You can add several Host in this file.
Remote command execution
You want to execute a single command on a distant computer without connecting to the computer. The command is the last item of the ssh command line
ssh RemoteComputer "command"
The output is redirected on the your pipe.
Example : a command to list the files own by user on the /tmp directory of RemoteComputer
ssh RemoteComputer "ls -hSBCF -l /tmp|grep user"
(to be done)