Configure SSH automation login

If you need a guide on how to configure SSH automation login, here is the steps.

SSH Automatic Login

Of course this is not the right phrase for it. It should be something like “key-based authorization with SSH”. Or simply “publickey authorization”. Or “unattended ssh login”. But I guess you know what I mean.

Here are the steps:

1. Create a public ssh key, if you haven’t one already.
Look at ~/.ssh. If you see a file named then you obviously already have a public key. If not, simply create one. ssh-keygen -t dsa should do the trick.
Please note that there are other types of keys, e.g. RSA instead of DSA. I simply recomend DSA, but keep that in mind if you run into errors.

2. Make sure your .ssh dir is 700:
chmod 700 ~/.ssh

3. Get your public ssh key on the server you want to login automatically.
A simple scp ~/.ssh/ is ok.

4. Append the contents of your public key to the ~/.ssh/authorized_keys and remove it.
Important: This must be done on the server you just copied your public key to. Otherwise you wouldn’t have had to copy it on your server.
Simply issue something like cat >> .ssh/authorized_keys while at your home directory.

5. Instead of steps 3 and 4, you can issue something like this:
cat ~/.ssh/ | ssh -l remoteuser 'cat >> ~/.ssh/authorized_keys'

6. Remove your public key from the home directory on the server.

7. Done!

You can now login:
ssh -l remoteuser or ssh without getting asked for a password.

That’s all you need to do.

I found these steps from :

If you working with Solaris, may be this guide will help you.

Setting Up SSH For No Password

Peter Cvar, April 2006

This setup will allow you to log in to another account without having to provide the password.

man ssh-keygen is a start, but it might need some clarifying for beginners.

This Tech Tip concentrates on SSH2, the second version of SSH. Don't use the first version any longer; it contains security bugs. Also, older versions of the second version might contain security bugs. Check with ssh -V that your version matches the latest one available from OpenSSH.

If you can't find any of the SSH commands (ssh and scp, for instance) on your system, get the SSH package first and install it. This suite should also install the ssh-keygen command on your machine. Make sure that SSH is installed on every system that you want to access. Starting from the Solaris 9 OS, SSH is included in the distribution.

If you can't find a package suitable for your version, refer to the OpenSSH web site for the source, and then download, unpack, read the README, compile, and install. Systems missing OpenSSL have to add that package as well for SSH to work. Test, for example, ssh localserver; this will create a .ssh subdirectory in your home directory.

In your ~/.ssh directory, create your personal SSH key:

server1:~/.ssh> ssh-keygen -t dsa

This creates id_dsa and in ~/.ssh.

If you want to enable remote connections that don't require a password, do not enter a passphrase. If you do enter a non-empty passphrase, when connecting to the remote server you will be asked for the passphrase instead of the password!

Append the public key to the file authorized_keys2:

server1:~/.ssh> cat >> authorized_keys2

Don't worry if authorized_keys2 does not yet exist before you execute this command.

Sun provides SSH in the Solaris OS starting from release 9, but uses SSH version 1 naming conventions. On the Solaris 9 OS, use the authorized_keys file instead of authorized_keys2.

Now you should already be able to make a secure connection to your own machine, using this account, without having to provide a password.

Check permissions on your keys and refer to the man page. The id_dsa file should be private, the other keys world readable. On the remote server, generate keys in the same way for your account on that server.

Copy your public key into ~/.ssh/ on the remote server.

server1:~/.ssh> scp server2:/your/remote/home/.ssh/
user@server2's password: 100% |*****************************| 236 00:00

Do the same thing for the remote key; copy it into your local ~/.ssh directory:

server1:~/.ssh> scp server2:/your/remote/home/.ssh/ ./
user@server2's password: 100% |*****************************| 236 00:00

On both servers, append the key from the other server to the file authorized_keys2:

server1:~/.ssh> cat >> authorized_keys2

And also for the second server:

user@server2:~/.ssh> cat >> authorized_keys2

That's it! Try to connect to the remote server now. It should do something similar to this:

server1:~/.ssh> ssh server2
Last login: Mon Nov 21 16:23:26 2005 from :0

If things don't work, check the logs, possibly in /var/log/secure. This file contains useful information, such as:

Nov 21 10:24:41 ocean sshd[26446]: Authentication refused: bad ownership or
modes for file /home/name/.ssh/authorized_keys

Most likely, the problem is too many permissions.

By default, the Solaris OS doesn't allow ssh as root. Edit /etc/ssh/sshd_config and change the PermitRootLogin directive. Restart sshd for these changes to take effect.

Also on the Solaris OS, make sure that you use the file ~/.ssh/authorized_keys, without the two suffixes. The Solaris OS uses version 2 of ssh but without the version 2 naming convention.

A typical entry in ~/.ssh/authorized_keys(2) looks like this:

ssh-dss FGKJTJUVFMAAACBAOk6t1czfh7nV9sb0syK1CebJ/6nwLb9OPLr0LcqcE1J8GYbePDVfg\

Line broken at the '\' for readability.

If you can't connect to a remote server using a particular user name on that server, check that the appropriate key is in your authorized_keys(2) file, and that the remote server name, encryption method, and user name exist.

Use ssh -v, scp -v or sftp -v to display verbose output and analyze any other problems that you might come across.

This guide is from :


Popular posts from this blog

Setup mail server with ldap authentication in docker

How to allow non root user to execute hping command ?

Boot Acronis from PXE