SSH和Security知识(1)
2020-02-22 本文已影响0人
lenka01
//查看本地所有的keychain
security list-keychains -s ~/Library/Keychains/login.keychain
//打开钥匙串
security unlock-keychain -p 123456 ~/Library/Keychains/login.keychain-db
//导入证书
security import pck.p12 -k '~/Library/Keychains/login.keychain-db' -P 123456 -A -T '/usr/bin/codesign'
//清理xcode工程
xcodebuild clean
//展示钥匙串证书
security find-identity -v -p codesigning
//证书样例
10D75939ED6903E5A11413BEA36D131747A6EBFA "iPhone Distribution: Guangdong Business Data Processing Co. Ltd"
//删除证书
security delete-certificate -c 'iPhone Distribution: Guangdong Business Data Processing Co. Ltd' -t
security delete-certificate -Z 'sha1'
//远程开启屏幕共享,前提已连接ssh
ssh 用户名@192.168.1.1
//开启屏幕共享
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -clientopts -setvnclegacy -vnclegacy yes -clientopts -setvncpw -vncpw mypasswd -restart -agent -privs -all
其中mypasswd为你的VNC密码
//关闭
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -deactivate -configure -access -off
//为所有用户开启vnc
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -off -restart -agent -privs -all -allowAccessFor -allUsers
//开始远程控制
vnc://192.168.1.1
//expect 脚本
#!/usr/bin/expect
set timeout 10
#expect执行操作默认会等待10s,-1为一直等待
#读取输入参数
set remotehost [lindex $argv 0]
set remotepass [lindex $argv 1]
spawn ssh $remotehost
expect "*\[Pp\]assword*"
send "$remotepass\r"
interact
interact和expect eof都可以结束进程操作,不同的是:interact结束后会回到当前操作,而expect eof会退出整个操作,相当于ctl+c