{"id":295,"date":"2013-01-10T12:28:47","date_gmt":"2013-01-10T12:28:47","guid":{"rendered":"http:\/\/vickistan.com\/?p=295"},"modified":"2025-01-13T16:25:47","modified_gmt":"2025-01-13T16:25:47","slug":"ssh-stuff","status":"publish","type":"post","link":"https:\/\/vickistan.com\/?p=295","title":{"rendered":"SSH Agent stuff"},"content":{"rendered":"<p><strong>Use the -i option to specify a new key<\/strong><\/p>\n<p>ssh -i newkey root@108.166.84.188<\/p>\n<p><strong>How to strip a passphrase from an openssl key<\/strong><\/p>\n<p>cp filename.key filename.key.encrypted<br \/>\nopenssl rsa -in filename.key -out filename.key.nopass<br \/>\ncp filename.key.nopass filename.key<\/p>\n<p><strong>How to add or change a passphrase to an openssl key<\/strong><\/p>\n<p>If you created an openssl key without a password or if you need to change the password:<\/p>\n<p>ssh-keygen -p -f ~\/.ssh\/id_rsa<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p><strong>Starting the SSH Agent<\/strong><\/p>\n<p>There are two ways to start the ssh-agent. Either will do the trick.<\/p>\n<p>Start the ssh-agent using backquotes to pass information about the agent back to the shell.<\/p>\n<p>`eval ssh-agent` runs an ssh-agent by forking a process off your current<br \/>\nlogin shell. It outputs some commands to set environment variables:<br \/>\nSSH_AUTH_SOCK or SSH2_AUTH_SOCK and SSH_AGENT_PID or SSH2_AGENT_PID. The eval part causes the shell to interpret the commands output by<br \/>\nssh-agent, thereby setting the environment variables. (If you leave off<br \/>\nthe eval, you\u2019ll see the output.) The problem is that, because it got<br \/>\nforked, it is inaccessible to the shell and keeps running until killed<br \/>\nmanually. And even then the environment variables remain set until you<br \/>\nunset them.<\/p>\n<p><strong>Start the ssh-agent and spawn a subshell.<\/strong><\/p>\n<p>ssh-agent bash<br \/>\n(ssh-agent \/bin\/sh, ssh-agent \/bin\/csh, ssh-agent $SHELL, ssh-agent<br \/>\nmy-shell-script all work too btw)<\/p>\n<p>With this method, the ssh-agent process runs in the foreground, spawning<br \/>\na subshell and setting the environment variables up automatically. The<br \/>\nrest of the login session runs in the subshell. When the shell is killed<br \/>\nthe cleanup is done automatically. Of course, any background processes<br \/>\nrun before initiating the ssh-agent in this way are not accessible from<br \/>\nwithin the subshell.<\/p>\n<p>1) Add root\u2019s identity<br \/>\nssh-agent bash<br \/>\n(ssh-agent \/bin\/sh, ssh-agent \/bin\/csh, ssh-agent $SHELL, ssh-agent<br \/>\nmy-shell-script all work too btw)<br \/>\n2) Add the ssh key to the agent<br \/>\nssh-add ~\/.ssh\/id_root_dsa<br \/>\n3) Log onto a machine setup to use ssh-keys<br \/>\nssh -2 -A root@$MACHINENAME<\/p>\n<p>Copying data from one machine to a tape drive on another.<\/p>\n<p>1) Add root\u2019s identity<br \/>\nssh-agent bash<br \/>\n(ssh-agent \/bin\/sh, ssh-agent \/bin\/csh, ssh-agent $SHELL, ssh-agent<br \/>\nmy-shell-script all work too btw)<br \/>\n2) Add the ssh key to the agent<br \/>\nssh-add ~\/.ssh\/id_root_dsa<br \/>\n3) Pipe the output of tar to a machine setup to use ssh-keys<\/p>\n<p>tar zcvf \u2013 \/scratch\/vickistan\/cl-pdk\/ |ssh -A root@$MACHINENAME \u201ccat &gt; \/dev\/nst2\u2033<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use the -i option to specify a new key ssh -i newkey root@108.166.84.188 How to strip a passphrase from an openssl key cp filename.key filename.key.encrypted openssl rsa -in filename.key -out filename.key.nopass cp filename.key.nopass filename.key How to add or change a &hellip; <a href=\"https:\/\/vickistan.com\/?p=295\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,7],"tags":[],"class_list":["post-295","post","type-post","status-publish","format-standard","hentry","category-linux","category-ssh"],"_links":{"self":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=295"}],"version-history":[{"count":11,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/295\/revisions"}],"predecessor-version":[{"id":934,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/295\/revisions\/934"}],"wp:attachment":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}