Then add your keys to it – you’ll need to enter your passphrase for any encrypted keys:<\/p>\n
ssh-add ~\/dir\/mykey<\/pre>\nHijacking SSH Agents<\/h3>\n
If you see SSH agents running on a pentest (process called “ssh-agent”), you might be able to use it to authenticate you to other hosts – or other accounts on that host. \u00a0Check out ~\/.ssh\/known_hosts for some ideas of where you might be able to connect to.<\/p>\n
You can use any agents running under the account you compromised. \u00a0If you’re root you can use any SSH agent.<\/p>\n
SSH agents listen on a unix socket. \u00a0You need to figure where this is for each agent (e.g.\u00a0\/tmp\/ssh-tqiEl28473\/agent.28473). You can then use the agent like this:<\/p>\n
export \u00a0SSH_AUTH_SOCK=\/tmp\/ssh-tqiEl28473\/agent.28473\r\nssh-add -l # lists the keys loaded into the agent\r\nssh user@host # will authenticate you if server trusts key in agent<\/pre>\nThis command illustrates how you could inspect the environment of every ssh-agent process on a Linux system. \u00a0It should yield a list of unix sockets for SSH agents.<\/p>\n
ps auxeww | grep ssh-agent | grep SSH_AUTH_SOCK | sed 's\/.*SSH_AUTH_SOCK=\/\/' | cut -f 1 -d ' '<\/pre>\nAgent Forwarding<\/h3>\n
If you enable SSH agent forwarding then you’ll be able to carry on using the SSH agent on your SSH client during your session on the SSH server. \u00a0This is potentially insecure because so will anyone else who is root on the SSH server you’re connected to. \u00a0Avoid using this feature with any keys you care about.<\/p>\n","protected":false},"excerpt":{"rendered":"
SSH has several features that are useful during pentesting and auditing. \u00a0This page aims to remind us of the syntax for the most useful features. NB: This page does not attempt to replace the man page for pentesters, only to\u00a0supplement\u00a0it with some pertinent examples. SOCKS Proxy Set up a SOCKS proxy on 127.0.0.1:1080 that lets […]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":[],"categories":[39],"tags":[19,59],"_links":{"self":[{"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/posts\/194"}],"collection":[{"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/comments?post=194"}],"version-history":[{"count":20,"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/posts\/194\/revisions"}],"predecessor-version":[{"id":241,"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/posts\/194\/revisions\/241"}],"wp:attachment":[{"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/media?parent=194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/categories?post=194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pentestmonkey.net\/wp-json\/wp\/v2\/tags?post=194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}