{"id":79084,"date":"2026-11-17T01:55:00","date_gmt":"2026-11-17T01:55:00","guid":{"rendered":"http:\/\/bangla.sitestree.com\/?p=79084"},"modified":"2026-11-17T01:55:00","modified_gmt":"2026-11-17T01:55:00","slug":"linux-intermediate-08-ssh","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=79084","title":{"rendered":"Linux Intermediate 08 \u2014 SSH Keys, Host Identity, and File Transfer"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/bangla.sitestree.com\/?name=linux-course-index\">Linux course index<\/a> \u00b7 <a href=\"https:\/\/bangla.sitestree.com\/?cat=1991\">Linux Intermediate category<\/a> \u00b7 Lesson 8 of 9<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>AI disclosure<\/strong> \u2014 AI-generated content, posted as is. AI can make mistakes. This lesson draws on the linked Open Education posts and adds original explanations or lab examples where useful. The newly written explanations and examples may be freely reused. Linked source material retains its own terms.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Learning goal<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Verify an SSH host\u2019s identity, use a passphrase-protected key, and transfer a non-sensitive file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Concepts and setup<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">SSH transport establishes encrypted communication. The server host key proves the server identity when pinned or verified. Your user key proves that you own a private key allowed for the remote account. Those keys solve different problems. Use a dedicated lab key and keep the private key on the client. Never suppress host-key checking to make a warning disappear.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use two VMs you control on an isolated network. Replace labuser and 192.168.56.20 with your own account and server. Use the VM console to verify the fingerprint on first connection.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Record a host fingerprint and connect<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Server console, if it uses this Ed25519 host key:\nssh-keygen -lf \/etc\/ssh\/ssh_host_ed25519_key.pub\n# Client:\ninstall -d -m 700 ~\/.ssh\nssh-keygen -t ed25519 -f ~\/.ssh\/oe-linux-lab -C oe-linux-lab\nssh-copy-id -i ~\/.ssh\/oe-linux-lab.pub labuser@192.168.56.20\nssh -i ~\/.ssh\/oe-linux-lab -o IdentitiesOnly=yes labuser@192.168.56.20 'id -un; hostname'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Possible output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>256 SHA256:EXAMPLE-FINGERPRINT labhost (ED25519)\n...\nlabuser\nlabhost<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Use an unused key filename and give the key a passphrase. ssh-copy-id assumes an authorized way to sign in the first time. Verify the client prompt against the console&#8217;s actual fingerprint before accepting.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Transfer a fixture and confirm content<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>lab=$(mktemp -d)\nprintf 'Linux SSH lab\\n' &gt; &quot;$lab\/message.txt&quot;\nscp -i ~\/.ssh\/oe-linux-lab -o IdentitiesOnly=yes &quot;$lab\/message.txt&quot; labuser@192.168.56.20:oe-lab-message.txt\nssh -i ~\/.ssh\/oe-linux-lab -o IdentitiesOnly=yes labuser@192.168.56.20 'cat ~\/oe-lab-message.txt'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Possible output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>message.txt                   100%   14 ...\nLinux SSH lab<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Use a fresh remote filename. Remove the fixture and the specific lab public key from authorized_keys when retiring the lab. Leave any other keys alone.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Questions only<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Quick-check questions<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li>Why should only the public user key be installed on the server?<\/li>\n\n\n<li>What should you do if a previously known host key changes unexpectedly?<\/li>\n\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Assessment questions<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li>Distinguish Permission denied from Connection refused in this lab.<\/li>\n\n\n<li>State where to verify the new host key before trusting it.<\/li>\n\n\n<li>How would you confirm that you are using the intended client identity rather than another configured key?<\/li>\n\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Questions and answers<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Quick-check answers<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li><strong>Why should only the public user key be installed on the server?<\/strong><br><strong>Answer<\/strong> \u2014 The private key enables authentication and should remain under the client&#8217;s control.<\/li>\n\n\n<li><strong>What should you do if a previously known host key changes unexpectedly?<\/strong><br><strong>Answer<\/strong> \u2014 Stop. Verify through a trusted separate channel, such as the VM console, before updating the saved host entry.<\/li>\n\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Assessment answer key<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li><strong>Distinguish Permission denied from Connection refused in this lab.<\/strong><br><strong>Answer<\/strong> \u2014 Permission denied usually follows a successful transport and failed authorization or authentication. Connection refused usually points earlier to the listening endpoint or an active rejection.<\/li>\n\n\n<li><strong>State where to verify the new host key before trusting it.<\/strong><br><strong>Answer<\/strong> \u2014 Record the fingerprint at the VM console or another approved trusted source. Compare it to what the client reports.<\/li>\n\n\n<li><strong>How would you confirm that you are using the intended client identity rather than another configured key?<\/strong><br><strong>Answer<\/strong> \u2014 Use -i with the intended key and -o IdentitiesOnly=yes. Inspect a verbose client trace if necessary, without publishing identifying details.<\/li>\n\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Source articles on this site<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=14027\">SSH\/SSHD\/OpenSSH in CentOS\/Redhat Linux<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=78587\">SSH Interaction from AI Tools<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=22776\">Ubuntu: Creating a user with SSH access and write permission to the web-application folder #Root #By Sayed Ahmed<\/a><\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Continue the course<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Previous lesson 07 \u2014 IP Addresses, Routes, and Name Resolution. Next lesson 09 \u2014 Block Devices, Filesystems, and Mounts.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/bangla.sitestree.com\/?name=linux-course-index\">Linux course index<\/a> \u00b7 <a href=\"https:\/\/bangla.sitestree.com\/?cat=1991\">Linux Intermediate category<\/a> \u00b7 Lesson 8 of 9<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Verify an SSH host\u2019s identity, use a passphrase-protected key, and transfer a non-sensitive file.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1991],"tags":[],"class_list":["post-79084","post","type-post","status-publish","format-standard","hentry","category-linux-intermediate","item-wrap"],"jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":79102,"url":"http:\/\/bangla.sitestree.com\/?p=79102","url_meta":{"origin":79084,"position":0},"title":"Linux Administration Course \u2014 Start Here and Lesson Index","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"A 33-lesson Linux course from shell fundamentals to server administration, performance, and a recovery capstone.","rel":"","context":"In &quot;Linux Basics&quot;","block_context":{"text":"Linux Basics","link":"http:\/\/bangla.sitestree.com\/?cat=1990"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79083,"url":"http:\/\/bangla.sitestree.com\/?p=79083","url_meta":{"origin":79084,"position":1},"title":"Linux Intermediate 07 \u2014 IP Addresses, Routes, and Name Resolution","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Separate the problems of link state, addressing, routing, name resolution, and listening services.","rel":"","context":"In &quot;Linux Intermediate&quot;","block_context":{"text":"Linux Intermediate","link":"http:\/\/bangla.sitestree.com\/?cat=1991"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79085,"url":"http:\/\/bangla.sitestree.com\/?p=79085","url_meta":{"origin":79084,"position":2},"title":"Linux Intermediate 09 \u2014 Block Devices, Filesystems, and Mounts","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Distinguish a block device from a filesystem and a mount point, and inspect each layer without changing it.","rel":"","context":"In &quot;Linux Intermediate&quot;","block_context":{"text":"Linux Intermediate","link":"http:\/\/bangla.sitestree.com\/?cat=1991"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79082,"url":"http:\/\/bangla.sitestree.com\/?p=79082","url_meta":{"origin":79084,"position":3},"title":"Linux Intermediate 06 \u2014 Boot, Services, Logs, and Timers","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Trace the boot-to-service path, inspect logs, and create a timer that runs a tiny user service.","rel":"","context":"In &quot;Linux Intermediate&quot;","block_context":{"text":"Linux Intermediate","link":"http:\/\/bangla.sitestree.com\/?cat=1991"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79077,"url":"http:\/\/bangla.sitestree.com\/?p=79077","url_meta":{"origin":79084,"position":4},"title":"Linux Intermediate 01 \u2014 Users, Groups, sudo, and Special Permissions","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Inspect identity records, understand sudo, and build a group-inheriting directory in a disposable VM.","rel":"","context":"In &quot;Linux Intermediate&quot;","block_context":{"text":"Linux Intermediate","link":"http:\/\/bangla.sitestree.com\/?cat=1991"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":14027,"url":"http:\/\/bangla.sitestree.com\/?p=14027","url_meta":{"origin":79084,"position":5},"title":"SSH\/SSHD\/OpenSSH in CentOS\/Redhat Linux","author":"Sayed","date":"December 24, 2017","format":false,"excerpt":"Experiment with SSH\/SSHD\/OpenSSH in CentOS\/Redhat Linux Yes, from\u00a0 my history (Probably a review for the technical people, who already knew these sometimes in the past) 461 echo \"dec 24th, 2017\" 462 vim \/etc\/ssh\/sshd_config 463 echo \"SSH Related Commands\" 464 scp -> secure copy 465 tscp -> secure copy for windows\u2026","rel":"","context":"In &quot;\u09b2\u09bf\u09a8\u09be\u0995\u09cd\u09b8 \u098f\u09ac\u0982 \u0989\u09a8\u09bf\u0995\u09cd\u09b8 \u0964 Linux and Unix&quot;","block_context":{"text":"\u09b2\u09bf\u09a8\u09be\u0995\u09cd\u09b8 \u098f\u09ac\u0982 \u0989\u09a8\u09bf\u0995\u09cd\u09b8 \u0964 Linux and Unix","link":"http:\/\/bangla.sitestree.com\/?cat=1231"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/79084","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=79084"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/79084\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=79084"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=79084"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=79084"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}