{"id":4227,"date":"2014-09-06T09:14:15","date_gmt":"2014-09-06T14:14:15","guid":{"rendered":"https:\/\/secure.rosehosting.com\/blog\/?p=4227"},"modified":"2022-06-03T03:46:42","modified_gmt":"2022-06-03T08:46:42","slug":"ssh-login-without-password-using-ssh-keys","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/ssh-login-without-password-using-ssh-keys\/","title":{"rendered":"SSH login without password"},"content":{"rendered":"
[et_pb_section bb_built=”1″][et_pb_row][et_pb_column type=”4_4″][et_pb_text _builder_version=”3.1.1″ text_font=”Open Sans||||||||”]<\/p>\n
<\/p>\n
SSH or Secure SHELL is the most popular and trusted UNIX-based cryptographic network protocol. It can be used for secure data communication, remote server logins, remote command execution, and many other secure network services between two networked servers. Normally, password authentication is used to connect to a remote server via SSH. In this blog tutorial we will show you how to login to a remote Linux VPS<\/a> without password, using SSH keys. This method is more secure than using a password.<\/p>\n <\/p>\n First of all, we need to generate the public and private keys. We will use the RSA (Rivest-Shamir-Adleman) cryptosystem.<\/p>\n This will create 2048 bit public and private keys in the ‘\/root\/.ssh\/’ directory on your server<\/p>\n Create a new ‘.ssh’ directory on the remote server<\/p>\n Copy the newly generated public key to the remote server you want to SSH without password<\/p>\n Change the permissions of the public key and the ‘.ssh’ directory<\/p>\n Now, login to the remote server and configure the SSH server to accept key authentication. Open the SSH configuration file<\/p>\n And make sure that the following three options are not commented and\u00a0 ‘RSAAuthentication’ and ‘PubkeyAuthentication’ are set to ‘yes’.<\/p>\n Save the changes and restart the SSH server<\/p>\n That’s all. You should be able to the remote server without password<\/p>\n Of course, you don\u2019t have to do any of this if you use one of our Linux VPS Hosting<\/a> services, in which case you can simply ask our expert Linux admins to explain or set up SSH login without a password. They are available 24\u00d77 and will take care of your request immediately. You can also read our update on how to Disable or Enable SSH Root Login and Secure SSH Access in CentOS 7<\/a>.<\/p>\n PS.<\/span><\/strong> If you liked this post on\u00a0SSH login without password,\u00a0 please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n [\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":" [et_pb_section bb_built=”1″][et_pb_row][et_pb_column type=”4_4″][et_pb_text _builder_version=”3.1.1″ text_font=”Open Sans||||||||”] SSH or Secure SHELL is the most popular and trusted UNIX-based cryptographic network protocol. … <\/p>\nSSH login without password<\/h2>\n
ssh-keygen -t rsa\nGenerating public\/private rsa key pair.\nEnter file in which to save the key (\/root\/.ssh\/id_rsa): PRESS ENTER\nEnter passphrase (empty for no passphrase): PRESS ENTER\nEnter same passphrase again: PRESS ENTER\nYour identification has been saved in \/root\/.ssh\/id_rsa.\nYour public key has been saved in \/root\/.ssh\/id_rsa.pub.\nThe key fingerprint is:\n4a:91:e0:19:89:37:41:ce:3e:ff:56:2c:02:eb:65:cb root@LOCALSERVER\nThe key's randomart image is:\n+--[ RSA 2048]----+\n|\u00a0\u00a0 o=o\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\n|\u00a0 .+++ .\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\n|\u00a0\u00a0 .=.o\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\n|\u00a0\u00a0 ..\u00a0 .\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\n|\u00a0\u00a0\u00a0 oo. S.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\n|\u00a0\u00a0\u00a0 .++.. o\u00a0\u00a0\u00a0\u00a0\u00a0 |\n|\u00a0\u00a0 . +oo o\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\n|\u00a0\u00a0\u00a0 . E..\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\n|\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ..\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\n+-----------------+<\/pre>\n
ls \/root\/.ssh\/\nid_rsa\u00a0 id_rsa.pub<\/pre>\n
ssh root@REMOTE_SERVER mkdir -p .ssh<\/pre>\n
cat \/root\/.ssh\/id_rsa.pub | ssh root@REMOTE_SERVER 'cat >> \/root\/.ssh\/authorized_keys'<\/pre>\n
ssh root@REMOTE_SERVER \"chmod 700 .ssh; chmod 600 .ssh\/authorized_keys\"<\/pre>\n
nano \/etc\/ssh\/sshd_config<\/pre>\n
RSAAuthentication yes\nPubkeyAuthentication yes\nAuthorizedKeysFile\u00a0\u00a0\u00a0\u00a0\u00a0 %h\/.ssh\/authorized_keys<\/pre>\n
\/etc\/init.d\/sshd restart<\/pre>\n
ssh REMOTE_SERVER<\/pre>\n
\n