openssh-wrapper.OpenSSH Python ·¡ÆÛ | |
Áö±Ý ´Ù¿î·Îµå |
openssh-wrapper. ¼øÀ§ ¹× ¿ä¾à
±¤°í
- ƯÇã:
- BSD License
- °Ô½ÃÀÚ À̸§:
- NetAngels team
- °Ô½ÃÀÚ À¥»çÀÌÆ®:
- https://github.com/NetAngels/
openssh-wrapper. ű×
openssh-wrapper. ¼³¸í
OpenSSH Python ·¡ÆÛ ÀϺΠ»óȲ¿¡¼´Â OpenSSH SSH ¸í·É ÁÙ À¯Æ¿¸®Æ¼ ÁÖÀ§ÀÇ °£´ÜÇÑ ·¡ÆÛ°¡ Paramiko Machineryº¸´Ù ´õ ¹Ù¶÷Á÷ÇÕ´Ï´Ù. Openssh-Wrapper´Â ¿ø°Ý ¼¹ö¿¡¼ ¸í·ÉÀ» ½ÇÇàÇϱâ À§ÇØ SSH ÁÖÀ§ÀÇ ¶Ç ´Ù¸¥ ¾ãÀº ·¦ÆÛ¸¦ Á¦¾ÈÇÕ´Ï´Ù. OpenSSH Ŭ¶óÀ̾ðÆ®¿Í Python ÀÎÅÍÇÁ¸®ÅÍ°¡ ¼³Ä¡µÇ¾î ÀÖ´ÂÁö È®ÀÎÇÑ ´ÙÀ½ openssh-·¦ÆÛ ÆÐÅ°Áö¸¦ ¼³Ä¡ ÇÑ ´ÙÀ½ openssh_wrapper °¡Á® ¿À±â sshconnection >>> conn = sshconnection ( 'localhost', 'root') >>> ret = conn.run ( 'whoami') >>> Àμâ retcommand : whoamistdout : rootstderr : returnCode : 0 >>> ret.command'whoami '>>> ret.stdout'root'>>> ret.stderr ''>>> Ret.ReturnCode0IF Python ÀÎÅÍÇÁ¸®ÅÍ°¡ ¿ø°Ý ½Ã½ºÅÛ¿¡ ¼³Ä¡µÇ¸é ÆÄÀ̽ã Äڵ带 ¿ø°ÝÀ¸·Î ½ÇÇàÇÒ ¼öµµ ÀÖ½À´Ï´Ù. stdin >>> ret = conn.run ( 'whoami') >>> Àμâ conn.run ( 'print "hello world"', ÀÎÅÍÇÁ¸®ÅÍ = '/ usr / bin "Àμâ" /python'.stdouthello WorldYet ´Ù¸¥ »ç¿ëÀÚ °¡µæ ·¯ ¸Þ¼Òµå ¿É¼ÇÀº forward_ssh_agent (paramiko°¡ ¾ÆÁ÷ °¡Áö°íÀÖ´Â ±â´É)ÀÔ´Ï´Ù. ·çÆ® @ localhost°¡ÇÏÁö ¾Ê´Â µ¿¾È Foobar ¼¹ö¿¡ ´ëÇÑ Áö¿øÀ¸·Î ¾×¼¼½º ÇÒ ¼ö ÀÖ´Ù°í °¡Á¤ÇÏÁö ¾ÊÀ¸¹Ç·Î SSH ¿¡ÀÌÀüÆ® Àü´Þ $ eval`ssh-agent 'Agent PID 5272 $ ssh-addidentity°¡ Ãß°¡µÊ : /home/me/.ssh/id_rsa (/home/3/.ssh/id_rsa : python >>> conn = sshconnection ( 'localhost', 'root') >>> Àμâ conn.run ( 'ssh support @ foobar "whoami"', forward_ssh_agent = true) ) .StdoutSupportand ¸¶Ä§³» ·ÎÄÿ¡¼ ¿ø°Ý ÄÄÇ»ÅÍ¿¡¼ ÆÄÀÏÀ» º¹»çÇÏ´Â ¹æ¹ýÀ» º¸¿©ÁÖ´Â »ùÇÃÀÌ ÀÖ½À´Ï´Ù >>> fd = open ( 'test.txt', 'w') >>> fd.write ( 'hello world')> >> fd.close () >>> openssh_wrapper °¡Á® ¿À±â sshconnection >>> conn = sshconnection ( 'localhost', 'root') >>> conn.scp ( 'test.txt', target = '/ tmp')> >> Print Conn.run ( 'Cat /tmp/test.txt') .Stdouthello ¼¼°è ¿ä±¸ »çÇ× : ¡¤ ÆÄÀ̽ã
openssh-wrapper. °ü·Ã ¼ÒÇÁÆ®¿þ¾î