IMG-LOGO
공지사항 :

centos sshfs python 패스워드 자동 입력 스크립트

lmkfox - 2021-02-21 09:23:16 522 Views 0 Comment

#! /usr/bin/python

import pexpect

import time

username = "계정"

password = "패스워드"

host = "IP "

hostdirectory = "호스트"

mountpoint = "마운트 될 장소 "

option = "-o allow_other -o nonempty"

command = "sshfs " + username + "@" + host + ":" + hostdirectory + " " + mountpoint + " " + option

def start_sshfs():

    try:

        sshfs = pexpect.spawn(command)

        sshfs.expect(username + "@" + host + "'s password: ")

        time.sleep (0.1)

        sshfs.sendline (password)

        time.sleep (10)

        sshfs.expect (pexpect.EOF)

    except Exception, e:

        print str(e)

def main ():

    start_sshfs()

if __name__ == '__main__':

    main ()


댓글