ssh basics
SSH stands for 'Secure Shell'. ssh is used for remote login and executing commands on remote machines.
Usage
% ssh remote_username@remote_hostnameor just
% ssh remote_hostname
(this will assume the remote username same as the local login)
Using scp to copy files from one machine to another
% scp remote_host:path_to_the_file local_target_path
For direcotries, use -r option.
ssh works scp doesn't ?
When you ssh to a host, ~/.bashrc (if you are using bash) is sourced. This is the file where you keep all the initialization stuff like aliases and other customization stuff for your bash session. If this file has any echo statements or calls some other scripts which may produce some output on the console, scp gets confused by the output and breaks. Try moving all such commands to ~/.bash_profile or ~/.login file instead. These files are not sourced when you run scp. Please let us know if this tip solved your problem.
ssh without password
To be able to ssh without password, follow these easy steps.
- Generate a pair of private and public keys with ssk-keygen
ssh-keygen -t rsa
-t is the type of keys rsa for ssh version 1 and dsa for version 2 - The program asks for a pass-phrase. You may leave this blank if you do not want a pass-phrase to be asked. Pass-phrase can be changed anytime using -p option.
- The command shows where public and private keys are stored. Private key should be readable only by the owner.
- Copy the public key and put in ~/.ssh/authorized_keys on your remote host.
That's it ! If you should be able to ssh between your machine and the remote hosts without passwords. For more information, see man page of ssh-keygen.