How to SSH to a host without login

Here are 2 easy steps to ssh into a host without login:


Remote host IP:
Remote host Username: root

Note: We need OpenSSH to be installed on the remote host for this to work.

  1. From your PC run the following command:
root@mehrdust# ssh-keygen -t rsa

now a file named authorized_keys should have been created on you .ssh folder.

# ls -l /root/.ssh
-rw------- 1 root root 1679 2011-11-09 10:55 id_rsa
-rw-r--r-- 1 root root  402 2011-11-09 10:55

2. Run the following command to copy this key to the remote host:

# ssh-copy-id -i /root/.ssh/ root@
The authenticity of host ' (' can't be established.
RSA key fingerprint is ef:23:31:87:a9:fa:cc:e7:fd:d2:5a:1a:d9:e2:35:4a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (RSA) to the list of known hosts.
root@'s password:
Now try logging into the machine, with "ssh 'root@'", and check in:


to make sure we haven't added extra keys that you weren't expecting.

At this point the is copied to the remote host as authorized_keys. After this you can ssh root@ and login without being prompt for password.

You may also like