1import paramiko
2
3ip = 'your remote ip'
4username = 'your user_name'
5password = 'your password'
6
7path = 'your path you want to count file'
8
9ssh = paramiko.SSHClient()
10ssh.load_system_host_keys()
11ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
12ssh.connect(ip, username=username, password=password)
13sftp = ssh.open_sftp()
14ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command('cd ' + path + ' && ls | wc -l')
15
16print(ssh_stdout.read().decode("utf-8"))