Over a million developers have joined DZone.

Log Into a Remote Host Without a Password

Learn from Zemian Deng how to log into a remote host without using a password by setting up as the authorized client using ssh with Java.

· Performance Zone

Evolve your approach to Application Performance Monitoring by adopting five best practices that are outlined and explored in this e-book, brought to you in partnership with BMC.

Most remote systems are secured by SSH, and to gain remote control with terminal, you would need to


into the server. You will be prompted to login with your password on every session. To avoid typing password everytime, you need to setup as the authorized client. Here is how you can do that with ssh key.

First on your own client machine, generate the $HOME/.ssh/id_rsa.pub file:

bash> ssh-keygen
# When prompted to enter password, simply hit ENTER key to skip it!
bash> cat  ~/.ssh/id_rsa.pub
xxxyyyzzz zemian@myhost
# You will see a very long string instead of "xxxyyyzzz".

Now, you need to copy this public key string into your remote host. You need to ssh into the remote host with your valid password first to setup. If successful, the subsequent ssh into the remote host will not prompt you for password!

bash> ssh myremotehost
# Enter password to gain access

After you are in the remote host:

myremotehost> vim ~/.ssh/authorized_keys
#Paste and append the "xxxyyyzzz" into above file.

If you don’t already have the ~/.ssh/authorized_keys file on remote host, then create it, but ensure you don’t let other users or groups to access it. Use command like this to change the permission:

bash> chmod g-rw,o-rw ~/.ssh/authorized_keys

The cool thing about this is that it affects all ssh related commands, such as scp will now work without prompting you for password!

Have a productive day!

Learn tips and best practices for optimizing your capacity management strategy with the Market Guide for Capacity Management, brought to you in partnership with BMC.

hosted ,performance ,ssh ,remote host

Published at DZone with permission of Zemian Deng. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}