ssh Archives - The Linux GURUS https://thelinuxgurus.com/tag/ssh/ Learn Linux & DevOPS from THE LINUX GURUS Wed, 09 Dec 2020 16:53:32 +0000 en-US hourly 1 https://i0.wp.com/thelinuxgurus.com/wp-content/uploads/2020/01/cropped-thelinuxgurus_transparent_name.png?fit=32%2C32&ssl=1 ssh Archives - The Linux GURUS https://thelinuxgurus.com/tag/ssh/ 32 32 148921671 How to setup SSH login without password on Linux systems https://thelinuxgurus.com/how-to-setup-ssh-login-without-password/ https://thelinuxgurus.com/how-to-setup-ssh-login-without-password/#respond Wed, 09 Dec 2020 16:55:01 +0000 https://thelinuxgurus.com/?p=838 We might be required to setup ssh login without password for any number of reasons like remote file/commands execution, initiating backups with SCP, etc. In...

The post How to setup SSH login without password on Linux systems appeared first on The Linux GURUS.

]]>
We might be required to setup ssh login without password for any number of reasons like remote file/commands execution, initiating backups with SCP, etc. In this tutorial, we will learn to setup ssh login without password by using ssh public-private key-based authentication.

For this to work, we will first have to create ssh keys on one server, named SERVER A & then will copy the created public key to another Linux server, named SERVER B. The public key is copied into the file located in a user’s ssh directory i.e. ‘/home/user/.ssh/authorized_keys’.

Recommended Read: Simple guide to install POSTGRESQL on Centos/RHEL

Also Read: Simple guide to install POSTGRESQL on Ubuntu

Let’s discuss the process to create password less ssh authentication,


Setup ssh login without password

1- Login to SERVER A, and then run the following command to create ssh keys,

$ ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/user/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/user/.ssh/id_rsa.

Your public key has been saved in /home/user/.ssh/id_rsa.pub.

The key fingerprint is:

As mentioned above two files named ‘id_rsa’ & ‘id_rsa.pub’ will be created in ‘/home/user/.ssh’ directory. We need to copy the public key ‘id_rsa.pub’ to SERVER B.

2- You can use two methods to copy the public key to SERVER B, either 

  • You can copy the content of public key from SERVER A & copy it inside authorized_keys located inside the folder ‘/home/user/.ssh’,

$ cat ~/.ssh/id_rsa.pub | ssh user@remote-host(SERVER B) “cat >> ~/.ssh/authorized_keys” 

  • Or we can execute the following command to copy the public file contents from SERVER A to SERVER B,

$ ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote-host(SERVER B)

That’s it, we have now setup ssh login without password, but before we test it out we must make sure the permissions to files and folders are correct, i.e.

$ chmod 600 ~/.ssh/authorized_keys 

$ chmod 700 ~/.ssh/

3- Next, we can setup ssh login without password, 

$ ssh user@remote-host(SERVER B)

We can now access the SERVER B from SERVER A without it asking for password. We now end this tutorial, please feel free to send in any questions or queries using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.

The post How to setup SSH login without password on Linux systems appeared first on The Linux GURUS.

]]>
https://thelinuxgurus.com/how-to-setup-ssh-login-without-password/feed/ 0 838
Jenkins Server – Simple guide to add SSH credentials in jenkins server https://thelinuxgurus.com/jenkins-server-simple-guide-to-add-ssh-credentials-in-jenkins-server/ https://thelinuxgurus.com/jenkins-server-simple-guide-to-add-ssh-credentials-in-jenkins-server/#respond Mon, 03 Aug 2020 16:20:22 +0000 https://thelinuxgurus.com/?p=1189 Jenkins is one of the most popular tools for CI/CD & automation purposes. Jenkins is an open-source automation server that is used to reliably build,...

The post Jenkins Server – Simple guide to add SSH credentials in jenkins server appeared first on The Linux GURUS.

]]>
Jenkins is one of the most popular tools for CI/CD & automation purposes. Jenkins is an open-source automation server that is used to reliably build, test, and deploy software by developers around the world.

Here we are only going to discuss how to add ssh credentials in Jenkins server to make connections to other servers for the purpose of executing various scripts or commands on other servers. We can also make connections to other servers where some files are kept to execute them.

Recommended Read: Simple way to install ADB & FastBoot on Ubuntu

Also Read: Install & learn to use TCPDUMP with examples

In this tutorial, we will learn to add ssh credentials on the Jenkins server and how we can make an ssh connection with a remote server.


Pre-Requisites

We need to install a plugin named PUBLISH OVER SSH on the Jenkins server to add the ssh credentials. Once we have downloaded the plugin by visiting ‘Manage Jenkins’, then ‘Manage Plugins’ section. Here we need to click on the ‘Advanced’ tab & then click on ‘Upload plugin’ to upload the downloaded plugin.

Add ssh credentials on Jenkins server

Now to make an SSH connection, we would require ssh keys. Login to the REMOTE server & create the ssh key pair using the following command

$ cd ~/.ssh

$ ssh-keygen -t rsa -f jenkins_key

The first thing now we have to do is to add the public ssh key to the authorized_keys file, located in the same directory i.e. ~/.ssh. If authorized_keys file is not there, then it will be created with the following command,

$ cat jenkins_key.pub >> authorized_keys

Next, we need a private key that is created. Copy the contents of the private key named ‘jenkins_key’ & head back to the Jenkins page. Now go to ‘Manage Jenkins’ & then to ‘Configure System’. Upon scrolling down a bit, you will see a section named “SSH Server”. See screenshot below,

add ssh credentials in jenkins

Enter the mentioned values in the section,

Name = Name for the SSH connection,

Hostname = IP address or hostname of the remote server,

Username = username on the remote server,

add ssh credentials in jenkins

Now click on ‘Advanced’ & then check the box that says ‘Use password authentication, or use a different key’. Here you need to enter the passphrase for the ssh key (if entered during ssh key created, or else leave it empty) & then copy the contents of the private ssh key in the section named ‘Key’,

add ssh credentials in jenkins

Next click on ‘Test Configuration’ & if the provided information is correct then we will get a success message. To complete the setup, click on the ‘Save’ button located on the bottom of the page. SSH connection to the remote server has been created.

Now when the connection is required to the remote server, all we have to do is to use commands like ‘ssh user@remote-server command’ or ‘ssh user@remote-user sh script.sh’ or ‘scp /home/jenkins/test-file.txt user@remote-server:/home/user-directory ’. You will not be asked to enter any password to complete the operation.

This concluded the tutorial to add ssh credentials in the Jenkins server. You can contact us using the comment box below for any questions or queries.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.

The post Jenkins Server – Simple guide to add SSH credentials in jenkins server appeared first on The Linux GURUS.

]]>
https://thelinuxgurus.com/jenkins-server-simple-guide-to-add-ssh-credentials-in-jenkins-server/feed/ 0 1189