發表文章

目前顯示的是 5月, 2019的文章

python - Compare & Change File Name

圖片
In response to work needs write a python script for compare & change file name from excel file the script will compare field "servicetag" data in sheet "host" & file name Reference file (demo.xlsx)formate code import os , re , pandas # rename file count count = 0 # get script root path desdir=os.getcwd() # get xlsx file path datafile = input ( "xlsx file path \n " ) #load xlsx file data df = pandas.read_excel(datafile , sheet_name = 'host' ) df_df=pandas.DataFrame(df) for i in range ( len (df_df)): for file in os.listdir(desdir): if bool (re.search(df_df[ 'servicetag' ][i] , file)): #file name check if bool (re.search(df_df[ 'host' ][i] , file)): break ; else : count =count+ 1 os.rename(os.path.join(desdir , file) , os.path.join(desdir , df_df[ 'host' ][i]+ '-' +fi

ssh without password

圖片
just a note I want to write a scrpit to achieve the "ssh no password" function in nutanix cluster first look at the "ssh no password" part script.. maybe one day will write..just maybe for windows client to linux server ssh without password is easy simply speaking create private key and public key from windows save the windows public key in linux server and load private key file while you ssh to linux server this is setting step lab environment linux server: 10.31.1.70 windows client: 10.31.1.68 need tool: PuTTY PuTTYgen we can download from https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html windows 1. start puttygen-> generate 2. copy public key code to txt 3. save private key file linux 1. verify ssh config /etc/ssh/sshd_config sudo vi /etc/ssh/sshd_config PubkeyAuthentication yes AuthorizedKeysFile      .ssh/authorized_keys check fil