结合阿里云服务器,设置家中jetson tk1随时远程登陆

本文介绍如何通过阿里云服务器实现Jetson TK1的远程登录功能。首先需要配置路由器DMZ及SSH端口访问,接着在TK1上定时获取外网IP并上传到服务器,最后通过服务器查询TK1的公网IP进行远程登录。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

溪西创客小屋

原文链接:http://www.cnblogs.com/wyxy2005/p/4274467.html

前提条件:

1.路由配置dmz主机为tk1的ip ,设置路由器中ssh 端口22的访问权限

2.有一台远程服务器,服务器安装了php可以运行php文件(我使用的是阿里云)

家中tk1配置:

脚本python 部署在jetson tk1上,然后设置crontab 定时执行

把python脚本放在 /jetson/testip.py 

crontab -e 

*/10 * * * * /jetson/testip.py >>/dev/null 2>&1

/*----------------------testip.py-------------------------------*/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/python
import  re,httplib
conn  =  httplib.HTTPConnection( "1111.ip138.com" )
conn.request( "GET" "/ic.asp" )
r1  =  conn.getresponse()
data1  =  r1.read()
conn.close()
matchObj  =  re.search( r '(\d+)\.(\d+)\.(\d+)\.(\d+)' , data1, re.M|re.I)
if  matchObj:
     ip = matchObj.group()
     conn  =  httplib.HTTPConnection( "remotedIP" )
     conn.request( "GET" "/testip.php?debug=" + ip)
     r1  =  conn.getresponse()
     print  r1.read()
     conn.close()
else :
     print  "error"

2.远程服务器配置,直接在php网站目录下放下面php代码 

/*------------testip.php--------------*/

<?php
$ipfile =  "/var/log/homeip.txt" ;
if  (isset($_GET[ 'debug' ])) {
     $ip =  $_GET[ 'debug' ];
     preg_match_all( '|\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}|' , $ip, $out, PREG_PATTERN_ORDER);
     if  (!empty($out[ 0 ][ 0 ])) {
         $ip =  $out[ 0 ][ 0 ];
     } else  {
         die();
     }
     $myfile =  fopen($ipfile, "w" ) or  die( "Unable to open file!" );
     echo ($ip);
     fwrite($myfile, $ip);
     fclose($myfile);
     die();
}
$myfile =  fopen($ipfile, "r" ) or  die( "Unable to open file!" );
echo fread($myfile, filesize($ipfile));
fclose($myfile);
die();

 使用:

http://远程服务器ip/testip.php 

返回得到家中jetson tk1 的公网地址,然后 ssh ip就可以登陆上家里的机器了

-----------------------------------注:

ssh ubuntu@192.168.2.123

远程需要显示图形界面:

ssh -X IP

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值