centos 6.5

rm /etc/shadowsocks.json
cat >>/etc/shadowsocks.json <<EOF
{
    "server":"0.0.0.0",
    "server_ipv6":"[::]",
    "server_port":$1,
    "local_address":"127.0.0.1",
    "local_port":1080,
    "password":"cnmf.net.cn",
    "timeout":130,
    "method":"aes-256-cfb",
    "protocol":"auth_sha1_v4",
    "protocol_param":"",
    "obfs":"http_simple",
    "obfs_param":"",
    "redirect":"",
    "dns_ipv6":false,
    "fast_open":false,
    "workers":1
}
EOF
/sbin/iptables -I INPUT -p tcp --dport $1 -j ACCEPT
/etc/init.d/iptables save
service iptables restart
/etc/init.d/shadowsocks restart

Python3.5

import sys
import paramiko
import random

def getport():
    return random.randint(20000,65000)


ip1 = xx
port = 22
user = xx
password1 = xx


ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip,port,user,password,timeout = 10)
newport=getport()
print(newport)
stdin,stdout,stderr = ssh.exec_command("sh /root/1.sh "+str(newport))
result = stdout.read()
print(result)
ssh.close()