如果你只是想避开使用ssh防火墙尝试tmate
下面是说明如何使用它进行远程设置
需要:
`
#!/bin/bash
#if Internet connection
if [[ $(ping -W 1 -c 1 8.8.8.8) == *", 0% packet loss,"* ]];
then
echo online;
#if connection already exists
if [[ -S /tmp/tmate.sock ]];
then
echo "aready up"
else
tmate -S /tmp/tmate.sock new-session -d
fi
tmate -S /tmp/tmate.sock wait tmate-ready
ssh=$(tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}')
ssh=$(sed 's~ssh ~~g' <<< $ssh)
echo $ssh
#sends ssh session to you
curl "https://script.google.com/macro/s/{{ google script location }}/exec?id={{ unique id for raspberry pi }}&ssh=$ssh" > /dev/null
else
#no Internet retry in 30 seconds
echo offline;
sleep 30s
bash {{ location of this script }}
fi
对与@reboot {{ user }} bash {{ location of script }}
登录设置的用户cron作业的树莓派上面的代码谷歌和去http://script.google.com/当输入该代码
`
function doGet(e) {
var id = e.parameter.id;
var ssh = e.parameter.ssh;
var ss = SpreadsheetApp.openByUrl("{{ url of google spread sheet to dump data to }}").getActiveSheet();
var lr = ss.getLastRow();
var data = ss.getRange(1,1,lr,1).getValues();
data = data.join("`").split("`");
var loc = data.indexOf(id);
if(loc != -1){
ss.getRange(loc+1,2).setValue(ssh);
}else{
ss.appendRow([id,ssh]);
}
}
现在在发布命中部署的谷歌脚本作为Web应用程序甚至允许匿名,现在你有你的谷歌脚本网址。
注:
- 任何与{{东西}}是你
- 是输入端。如果树莓派会重新启动谷歌将覆盖与新
老SSH位置所有超越tmate的东西只是在失去电源或需要重启的情况下重新建立连接