<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Archiwa ssh - soban</title>
	<atom:link href="https://soban.pl/category/ssh/feed/" rel="self" type="application/rss+xml" />
	<link>https://soban.pl/category/ssh/</link>
	<description>IT, Linux, Servers, Security</description>
	<lastBuildDate>Sat, 25 Feb 2023 22:12:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>Increasing the security of the ssh service</title>
		<link>https://soban.pl/increasing-the-security-of-the-ssh-service/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Fri, 05 Nov 2021 15:06:21 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Kali]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[ssh]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=305</guid>

					<description><![CDATA[<p>Nowadays, many bots or hackers look for port 22 on servers and try to log in. Usually, the login attempt is made as the standard linuxe root user. In this short article, I will describe how to create a user that will be able to log in as root and change the default ssh port [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/increasing-the-security-of-the-ssh-service/">Increasing the security of the ssh service</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Nowadays, many bots or hackers look for port 22 on servers and try to log in. Usually, the login attempt is made as the standard linuxe root user. In this short article, I will describe how to create a user that will be able to log in as root and change the default ssh port 22 to 2222. Let&#8217;s go:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">useradd -m soban -s /bin/bash</pre></div>



<p>This way we created the user &#8216;soban&#8217; and assigned it the default shell &#8216;/bin/bash&#8217;. </p>



<p>We still need to set a password for the user &#8216;soban&#8217;:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># passwd soban</pre></div>



<p>In the next step, let&#8217;s add it to &#8216;/etc/sudoers&#8217; so that it can become root. Keep in mind that once the user can get root, he will be able to do anything on the machine!</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># vi /etc/sudoers</pre></div>



<p>Please add this entry below:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#user can made sudo on root (sudo su -)
soban ALL=(ALL) NOPASSWD: ALL</pre></div>



<p>How can we test whether the user has the ability to log in as root? Nothing easier, first we&#8217;ll switch to the user we just created:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># su - soban</pre></div>



<p>To list the possible sudo commands, just type the command:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ sudo -l</pre></div>



<p>Finally, to confirm whether it is possible to log in as root, you should issue the command:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># sudo su -</pre></div>



<p>Now that we have a root user ready, let&#8217;s try disabling ssh logon directly and change the default port. To do this, go to the default configuration of the ssh service, which is located in &#8216;/etc/ssh/sshd_config&#8217;:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># vi /etc/ssh/sshd_config</pre></div>



<p>We are looking for a line containing &#8216;Port&#8217; &#8211; it can be hashed, so it should be unhashed and &#8216;PermitRootLogin&#8217;. Then set them as below:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">Port 2222
PermitRootLogin no</pre></div>



<p>In this way, we changed the default port 22 to 2222 and disallowed the possibility of logging in directly to the root user. However, the ssh service still needs to be reloaded, in debian or kali linux we do it like this:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># service sshd restart</pre></div>



<p>In this way, we have managed to create a user who can safely log into the ssh service and become root. In addition, after changing the port, we will not go out on port 22 scans, which by default is set and scanned by a potential burglar. Installing the fail2ban service is also a very good improvement in security.</p>
<p>Artykuł <a href="https://soban.pl/increasing-the-security-of-the-ssh-service/">Increasing the security of the ssh service</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Securely Copy Files (scp) tool to copying files by ssh</title>
		<link>https://soban.pl/securely-copy-files-scp-tool-to-copying-files-by-ssh/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Wed, 03 Nov 2021 15:15:57 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Kali]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ssh]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=264</guid>

					<description><![CDATA[<p>A very good tool for securely copying files via the ssh protocol between machines is scp. It allows you to transfer files to the target machine as well as download from a given source. The tool is usually built into the system so it works on many distributions. Below I will present how you can send and download [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/securely-copy-files-scp-tool-to-copying-files-by-ssh/">Securely Copy Files (scp) tool to copying files by ssh</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>A very good tool for securely copying files via the ssh protocol between machines is <strong>scp</strong>. It allows you to transfer files to the target machine as well as download from a given source. The tool is usually built into the system so it works on many distributions. Below I will present how you can send and download files. For correct file transfer, running ssh service is required, because it is the basis of scp operation. Of course, when using the tool, you can specify the port as the parameter, provided that it has been changed. The standard port used by the ssh daemon is 22. </p>



<p>In Linux, <code>scp</code> (Secure Copy) is a command-line utility used for securely transferring files between local and remote systems. It is a secure alternative to <code>cp</code>, which is not secure when transferring files over a network.</p>



<p>The <code>scp</code> command is commonly used for copying files to or from a remote server. It uses the SSH protocol to securely transfer files and provides the same level of security as SSH. The syntax of the <code>scp</code> command is as follows:</p>



<pre class="wp-block-preformatted">scp [options] [source] [destination]
</pre>



<p>Here, <code>[source]</code> is the file or directory you want to copy, and <code>[destination]</code> is the location where you want to copy the file or directory.</p>



<p>Some common options used with the <code>scp</code> command are:</p>



<ul class="wp-block-list">
<li><code>-r</code>: Copies directories recursively</li>



<li><code>-P</code>: Specifies the port number to use for the SSH connection</li>



<li><code>-i</code>: Specifies the path to the identity file used for authentication</li>
</ul>



<p>For example, to copy a file named <code>file.txt</code> from a remote server to the local machine, you would use the following command:</p>



<pre class="wp-block-preformatted">scp user@remote:/path/to/file.txt /path/to/local/directory/
</pre>



<p>This command will copy the file from the remote server to the local machine at the specified directory.</p>



<p>Similarly, to copy a directory named <code>dir</code> from the local machine to a remote server, you would use the following command:</p>



<pre class="wp-block-preformatted">scp -r /path/to/local/dir user@remote:/path/to/remote/directory/
</pre>



<p>This command will copy the directory and its contents from the local machine to the remote server at the specified directory.</p>



<p id="block-80cf4e6e-5e48-4264-8427-981d64e77dcb">Let&#8217;s start by creating an example file that we will transfer:&nbsp;</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ echo “example text” &gt; example_file</pre></div>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://soban.pl/wp-content/uploads/2021/11/image.png" alt="" class="wp-image-265" width="397" height="46" srcset="https://soban.pl/wp-content/uploads/2021/11/image.png 591w, https://soban.pl/wp-content/uploads/2021/11/image-300x35.png 300w" sizes="(max-width: 397px) 100vw, 397px" /></figure>



<p id="block-80b0b13d-d72c-489c-862f-a26e6b3a5ddb">in the next step, let&#8217;s move on to uploading the file. In my case, the port from&nbsp;ssh&nbsp;has been changed to 2222:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ scp -P2222 example_file soban@soban.pl:~</pre></div>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="961" height="200" src="https://soban.pl/wp-content/uploads/2021/11/image-1.png" alt="" class="wp-image-266" srcset="https://soban.pl/wp-content/uploads/2021/11/image-1.png 961w, https://soban.pl/wp-content/uploads/2021/11/image-1-300x62.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-1-768x160.png 768w" sizes="(max-width: 961px) 100vw, 961px" /></figure>



<p id="block-2270aee8-8ab4-44c5-a7d3-09aa7306f03b">The first time you connect, you will be asked for a fingerprint.&nbsp;<br>As you can see, the file has been sent correctly.&nbsp;</p>



<p id="block-69c718e9-c6a5-473f-9890-502c73227342">Instead of the sign at the end of &#8216;<strong>~</strong>&#8216; we can specify where the target file should be placed (<strong>/tmp/example-path</strong>):&nbsp;</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ scp -P2222 example_file soban@soban.pl:/tmp/example-path</pre></div>



<p id="block-faaf0713-3c2f-4f09-811c-733812328d07">There are many combinations, you can send, for example, all files containing the ending (<strong>*.tar.gz</strong>) to the user&#8217;s home directory, which is just symbolized by &#8216;<strong>~</strong>&#8216;:&nbsp;</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ scp -P2222 *.tar.gz soban@soban.pl:~</pre></div>



<p id="block-693e63f4-f081-49a0-8ec3-50ec9bb4274f">An interesting parameter is the &#8216;<strong>-r</strong>&#8216; in&nbsp;scp&nbsp;where we can transfer entire folders, example using copying a folder from local machine to remote machine:&nbsp;</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ scp -P2222 -r /local/directory/ soban@soban.pl:/remote/directory/</pre></div>



<p id="block-5cc2af40-fe4f-41ef-985d-09ccf65dfd3d">OK, after the file has been successfully sent to the target machine, let&#8217;s delete the local file we created above and try to download it back:&nbsp;</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ rm example_file</pre></div>



<p id="block-405a4127-4b66-41aa-932c-0a6ea693375c">Next, let&#8217;s move on to downloading the file from the remote server to the local machine:&nbsp;</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ scp -P2222 soban@soban.pl:example_file ~</pre></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1024" height="267" src="https://soban.pl/wp-content/uploads/2021/11/image-2.png" alt="" class="wp-image-267" srcset="https://soban.pl/wp-content/uploads/2021/11/image-2.png 1024w, https://soban.pl/wp-content/uploads/2021/11/image-2-300x78.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-2-768x200.png 768w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p id="block-81b9ceca-5bbc-40b3-99fd-2fb566a53a28">Above I gave an example of how to send an entire folder from a local machine to a remote machine. The other way around, of course, we can also do it. To download a remote folder to a local machine, use the &#8216;<strong>-r</strong>&#8216; parameter:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ scp -P2222 -r soban@soban.pl:/remote/directory/ /local/directory/</pre></div>



<p id="block-de00c7dc-b45d-4764-bf89-b540f489dbea">The&nbsp;scp&nbsp;utility has more parameters, you can get them by reading the man page:&nbsp;</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ man scp</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="979" height="632" src="https://soban.pl/wp-content/uploads/2021/11/image-3.png" alt="" class="wp-image-268" srcset="https://soban.pl/wp-content/uploads/2021/11/image-3.png 979w, https://soban.pl/wp-content/uploads/2021/11/image-3-300x194.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-3-768x496.png 768w" sizes="auto, (max-width: 979px) 100vw, 979px" /></figure>



<p id="block-e294f3cd-4591-4784-b847-465ba0398866">It is worth paying attention to the &#8216;<strong>-l</strong>&#8216; parameter where we can set the limit of transferred files. This is useful when transferring larger files so as not to overload your connection.&nbsp;</p>



<p id="block-1f07f453-291e-4f0d-8cba-4097fa301380">If you are tired of constantly entering your password, I encourage you to read how you can connect to&nbsp;ssh&nbsp;without providing a password. Then copying files using&nbsp;<strong>scp</strong>&nbsp;will become more: <a href="https://soban.pl/generate-ssh-key-pair-in-linux/" target="_blank" rel="noreferrer noopener"><strong>generate ssh key pair in linux</strong></a>.</p>



<p>In my opinion, scp is good for transferring files quickly one time. However, as often you exchange files between machines a more convenient way is to use sshfs as described here: <a href="https://soban.pl/sshfs-great-tool-to-mount-remote-file-system/" target="_blank" rel="noreferrer noopener"><strong>sshfs great tool to mount remote file system</strong></a>.</p>
<p>Artykuł <a href="https://soban.pl/securely-copy-files-scp-tool-to-copying-files-by-ssh/">Securely Copy Files (scp) tool to copying files by ssh</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>sshfs great tool to mount remote file system</title>
		<link>https://soban.pl/sshfs-great-tool-to-mount-remote-file-system/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Fri, 22 Oct 2021 13:30:45 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Kali]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[sshfs]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=243</guid>

					<description><![CDATA[<p>SSHFS (SSH File System) is a secure file transfer system that enables users to remotely access and manage files on a remote server over an encrypted SSH (Secure Shell) connection. SSHFS uses the SSH protocol to establish a secure connection between the local and remote systems, which enables users to securely transfer files between the [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/sshfs-great-tool-to-mount-remote-file-system/">sshfs great tool to mount remote file system</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>SSHFS (SSH File System) is a secure file transfer system that enables users to remotely access and manage files on a remote server over an encrypted SSH (Secure Shell) connection. SSHFS uses the SSH protocol to establish a secure connection between the local and remote systems, which enables users to securely transfer files between the two systems.</p>



<p>To use SSHFS, the user needs to have SSHFS installed on their local system as well as the remote system that they want to connect to. Once SSHFS is installed, the user can mount the remote system as a local directory on their system, and access the remote files as if they were stored locally.</p>



<p>SSHFS provides a secure and convenient way to access and manage files on remote systems, without the need for additional software or complicated configuration. It also enables users to access files on remote systems using standard file operations, such as copying, moving, and deleting, making it a simple and effective way to manage files on remote systems.</p>



<p><strong><strong>SSH Filesystem</strong></strong> (<strong>sshfs</strong>) is a very useful tool for remotely transferring files over the ssh protocol. An additional advantage of the whole is encryption. This is a convenient way to mount a remote folder to delete files. Below I will try to briefly introduce how to install sshfs and how to mount the folder remotely. Additionally, we will make an entry in <strong>/etc/fstab</strong> at the end, so that the resource itself is mounted after restarting the system. Let&#8217;s move on to installing the tool itself: </p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># apt install sshfs</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="432" src="https://soban.pl/wp-content/uploads/2021/10/image-82-1024x432.png" alt="" class="wp-image-244" srcset="https://soban.pl/wp-content/uploads/2021/10/image-82-1024x432.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-82-300x127.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-82-768x324.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-82.png 1128w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>In this case, as you can see, the installation was done on kali linuxe, however the procedure is the same on debian.</p>



<p>Let&#8217;s move on to the file mounting itself, at this point I will point out that the default port is 22. In my case, however, the port has been changed to 2222. For services such as ssh, I try to change the default ports so as not to get caught by bots and not end up in the database such as <a href="https://www.shodan.io/" target="_blank" rel="noreferrer noopener">shodan.io</a>. The command itself in this case is very simple, but first we need to create a folder: </p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ mkdir /home/kali/myremotedir</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="402" height="65" src="https://soban.pl/wp-content/uploads/2021/10/image-83.png" alt="" class="wp-image-245" srcset="https://soban.pl/wp-content/uploads/2021/10/image-83.png 402w, https://soban.pl/wp-content/uploads/2021/10/image-83-300x49.png 300w" sizes="auto, (max-width: 402px) 100vw, 402px" /></figure>



<p>Let&#8217;s try to mount a remote folder:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ sshfs soban@soban.pl:/home/soban/ /home/kali/myremotedir -p 2222</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="148" src="https://soban.pl/wp-content/uploads/2021/10/image-84-1024x148.png" alt="" class="wp-image-246" srcset="https://soban.pl/wp-content/uploads/2021/10/image-84-1024x148.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-84-300x43.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-84-768x111.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-84.png 1089w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>During mounting, we will be asked if the fingerprint is correct. Then for the system password. The command itself can be disassembled into &#8216;<strong>soban</strong>&#8216; &#8211; this is the username. Then &#8216;<strong>soban.pl</strong>&#8216; is the domain name, you can also put the IP address here. The next &#8216;<strong>/home/soban</strong>&#8216; element is the folder that will be mounted. And after the space &#8216;<strong>/home/kali/myremotedir</strong>&#8216; we give the folder where the remote folder should be mounted. If everything went as planned, we can list &#8216;<strong>/home/kali/myremotedir</strong>&#8216; and it should list the contents of the remotely mounted folder &#8216;<strong>/home/soban</strong>&#8216;. Let&#8217;s list the contents of the &#8216;<strong>/home/kali/myremotedir</strong>&#8216; folder:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ ls -ltr /home/kali/myremotedir</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="159" src="https://soban.pl/wp-content/uploads/2021/10/image-85.png" alt="" class="wp-image-247" srcset="https://soban.pl/wp-content/uploads/2021/10/image-85.png 642w, https://soban.pl/wp-content/uploads/2021/10/image-85-300x74.png 300w" sizes="auto, (max-width: 642px) 100vw, 642px" /></figure>



<p>Let&#8217;s create a remote file:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ echo 'some text' &gt; /home/kali/myremotedir/example
$ ls -ltr /home/kali/myremotedir</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="664" height="259" src="https://soban.pl/wp-content/uploads/2021/10/image-86.png" alt="" class="wp-image-248" srcset="https://soban.pl/wp-content/uploads/2021/10/image-86.png 664w, https://soban.pl/wp-content/uploads/2021/10/image-86-300x117.png 300w" sizes="auto, (max-width: 664px) 100vw, 664px" /></figure>



<p>Now let&#8217;s unmount the remote folder and try listing it again:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ umount /home/kali/myremotedir
$ ls -ltr /home/kali/myremotedir</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="445" height="155" src="https://soban.pl/wp-content/uploads/2021/10/image-87.png" alt="" class="wp-image-249" srcset="https://soban.pl/wp-content/uploads/2021/10/image-87.png 445w, https://soban.pl/wp-content/uploads/2021/10/image-87-300x104.png 300w" sizes="auto, (max-width: 445px) 100vw, 445px" /></figure>



<p>As expected, the folder is empty and the file we created was created on a remotely mounted drive. After unmounting as you can see the file &#8216;<strong>/home/kali/myremotedir/example</strong>&#8216;.</p>



<p>The next step is to create a private key to mount the folder without entering a password. It is very important not to send nikmou your private key. How we can generate and add a public key to a remote server can be read here: &#8220;<a href="https://soban.pl/generate-ssh-key-pair-in-linux/" target="_blank" rel="noreferrer noopener">Generate SSH key pair in Linux</a>&#8220;.</p>



<p>Now we will try to add an entry to <strong>/etc/fstab</strong> which will allow automatic mounting on startup of the remote folder system.<br>To do this, edit the <strong>/etc/fstab</strong> entry and add this entry:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#edit this entry and put correct data
sshfs#soban@soban.pl:/home/soban /home/kali/myremotedir fuse auto,user,_netdev,reconnect,identityfile=/home/kali/.ssh/id_rsa,port=2222,uid=1000,gid=1000,allow_other 0 0</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="245" src="https://soban.pl/wp-content/uploads/2021/10/image-92-1024x245.png" alt="" class="wp-image-259" srcset="https://soban.pl/wp-content/uploads/2021/10/image-92-1024x245.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-92-300x72.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-92-768x184.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-92-1536x367.png 1536w, https://soban.pl/wp-content/uploads/2021/10/image-92.png 1698w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>It is important that all data is correct, in order to verify the parameters, you can use the command for this &#8216;<strong>id</strong>&#8216;:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># id kali</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="100" src="https://soban.pl/wp-content/uploads/2021/10/image-94-1024x100.png" alt="" class="wp-image-261" srcset="https://soban.pl/wp-content/uploads/2021/10/image-94-1024x100.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-94-300x29.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-94-768x75.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-94.png 1067w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Now we can move on to mounting the resource:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># mount /home/kali/myremotedir</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="895" height="118" src="https://soban.pl/wp-content/uploads/2021/10/image-93.png" alt="" class="wp-image-260" srcset="https://soban.pl/wp-content/uploads/2021/10/image-93.png 895w, https://soban.pl/wp-content/uploads/2021/10/image-93-300x40.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-93-768x101.png 768w" sizes="auto, (max-width: 895px) 100vw, 895px" /></figure>



<p>When mounting for the first time, we may be asked to accept and confirm that the fingerprint is correct. After verifying the correctness of mounting the remote resource, we can restart the system. One note here, the system may get up longer.</p>
<p>Artykuł <a href="https://soban.pl/sshfs-great-tool-to-mount-remote-file-system/">sshfs great tool to mount remote file system</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Generate SSH key pair in Linux</title>
		<link>https://soban.pl/generate-ssh-key-pair-in-linux/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Fri, 22 Oct 2021 12:32:08 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Kali]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[ssh]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=251</guid>

					<description><![CDATA[<p>A very convenient way to log into remote systems via ssh is without the use of passwords. Here it is very important not to share your private key with anyone. Currently, when trying to connect, I am asked for the password to the server: During the connection, we will be asked if the fingerprint is [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/generate-ssh-key-pair-in-linux/">Generate SSH key pair in Linux</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>A very convenient way to log into remote systems via ssh is without the use of passwords. Here it is very important not to share your private key with anyone. Currently, when trying to connect, I am asked for the password to the server:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ ssh soban@soban.pl -p2222</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="374" src="https://soban.pl/wp-content/uploads/2021/10/image-90-1024x374.png" alt="" class="wp-image-254" srcset="https://soban.pl/wp-content/uploads/2021/10/image-90-1024x374.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-90-300x109.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-90-768x280.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-90.png 1261w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>During the connection, we will be asked if the fingerprint is correct. Then enter the user password that is set on the remote server. During the ssh command &#8216;<strong>soban@soban.pl -p2222</strong>&#8216; I gave the username &#8216;<strong>soban</strong>&#8216; then the domain &#8216;<strong>soban.pl</strong>&#8216; and &#8216;<strong>-p2222</strong>&#8216; port <strong>&#8216;2222&#8217;</strong>. The default port after ssh is <strong>22</strong>, but in this case I changed it so that it does not come out on scans &#8211; this increases security as often bots / hackers look for port <strong>22</strong>, which is the default ssh port set. </p>



<p>Let&#8217;s move on to generating the key and copying it to the server:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ ssh-keygen -t rsa</pre></div>



<p>This is how the key generation looks like, I hit enter for each question:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="753" height="539" src="https://soban.pl/wp-content/uploads/2021/10/image-88.png" alt="" class="wp-image-252" srcset="https://soban.pl/wp-content/uploads/2021/10/image-88.png 753w, https://soban.pl/wp-content/uploads/2021/10/image-88-300x215.png 300w" sizes="auto, (max-width: 753px) 100vw, 753px" /></figure>



<p>As a result, a private key was generated: (<strong>/home/kali/.ssh/id_rsa</strong>) and a public key (<strong>/home/kali/.ssh/id_rsa</strong>)  that we will place on the remote server:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ ssh soban@soban.pl -p2222 "echo \"`cat ~/.ssh/id_rsa.pub`\" &gt;&gt; .ssh/authorized_keys"</pre></div>



<p>The last time we log in to the server by entering the password. When logging in, we will not be asked for a password now. This way we are able to add our public key (.ssh / authorized_keys) to the remote server. </p>



<p></p>
<p>Artykuł <a href="https://soban.pl/generate-ssh-key-pair-in-linux/">Generate SSH key pair in Linux</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
