ssh basics

SSH stands for 'Secure Shell'. ssh is used for remote login and executing commands on remote machines.

Usage

% ssh remote_username@remote_hostname
or 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.

  1. 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
  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.
  3. The command shows where public and private keys are stored. Private key should be readable only by the owner.
  4. Copy the public key and put in ~/.ssh/authorized_keys on your remote host.
For SSH2 keys, the file is ~/.ssh/authorized_keys2

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.

Back to Linux Tips

More Info

Don't forget to see our Tools' page and linux resources page
For Linux commands see - Useful Linux Tips

gnuServices interests

gnuServices tools...

Report Generation

Open Source

Report Generation is an integral part of enterprise application. We write Shell scripts for automation and Perl scripts for Report Generation of various kinds. More…

Knowledge Base

Website Applications

With Perl, PHP - We use CSS layouts which is the latest trends in web-designing. This has many advantages over the old-school web-design practices. If you would like to learn more about what it is, please visit www.zeldman.com. More…