SSH login without specifying a password

You sometimes want to have a shell script automatically log on to another server, e.g. for transferring files. Sharing a key is the way to go.

First, you have to create a key”

cd ~
ssh-keygen -t rsa

I usually answer with the default value (by typing on all questions).

Send this key to the computers you want to connect to without a password (in this example, you’ll want to connect to the remote computer as the user ‘root’):

export computer=server1.example.com
cat ~/.ssh/id_rsa.pub | ssh $computer ‘cat >> /root/.ssh/authorized_keys’

Verify you can ssh without entering a password:

ssh $computer

Tags:

Add new comment

Wiki Textile Syntax

  • You can enable syntax highlighting of source code with the following tags: [code], [blockcode], [asp], [linux], [c], [cpp], [c#], [delphi], [dos], [f#], [html], [ini], [java], [javascript], [mysql], [perl], [php], [postgresql], [python], [ruby], [sql], [text], [vb], [xml].
  • You can use Textile markup to format text.
  • Web page addresses and e-mail addresses turn into links automatically.

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.