前几天发的:用pm2管理frpc ,里面直接讲的是用pm2 start -x 来启动的。如果用yaml来启动的话,会有部分不同
原来我的配置文件是这样的:
XML/HTML代码
- apps:
- - name: frp #配置
- cwd: /Users/gouki/frp
- script: ./frpc
- exec_mode: fork
- # interpreter: php
- instances: 1
- args:
- - -c /Users/gouki/frp/frpc.ini
看起来好象一点问题没有。毕竟 frpc的启动本来也就是frpc -c xxxx.ini,但如果真是这样,你会发现一直报错:
XML/HTML代码
- 3|frp | open /Users/gouki/frp/frpc.ini: no such file or directory
嗯,这种中间有空格的参数在这里好象是不能用的。改成 -c=/Users/gouki/frp/frpc.ini ,一切恢复
OK,于是最终的代码是这样的:
XML/HTML代码
- apps:
- - name: frp #配置
- cwd: /Users/gouki/frp
- script: ./frpc
- exec_mode: fork
- # interpreter: php
- instances: 1
- args:
- - -c=/Users/gouki/frp/frpc.ini
就是这样简单。但真的浪费了我不少时间。
jq是linux命令行下读取和解析JSON的好工具。只是好象不能jq xxx.json这样的用法,但没事,可以通过管道符,cat xxx.json|jq 就OK了
在这里:https://www.tuicool.com/articles/vieMN3Q有详细的教程,写的非常完整,但如果简单的使用,并不需要完整的看完,只要记得几个用法就行
来个简单的数据:{"code":1,"msg":"ok","data":{"fields":["a","b","c"],"items":[{1,2,3},{11,22,33}],"other":[{"x":1,"y":1},{"x":2,"y":2}]}}
1、获取items节点: cat xxx.json|jq ".data.items"
2、获取items下第二条数据的第二个,即22. cat xxx.json|jq ".data.items[1][1]"
3、获取other下的所有x节点: cat xxx.json|jq ".data.other[].x"
是不是很方便?如果要自定义格式输出,还可以这样
1、将所有x节点用{"items":[]}格式输出: cat xxx.json| jq "{items: [ .data.other[].x ]}" ,
如果要看更多的用法,还是上面的网址里更详细一点。我这只是简单的用一下。。或者说是临时在服务器上测试数据,让自己看起来会比较方便一点。还有一个原因是我在服务器上用这个的最大理由。有时候JSON拿到的时候中文都是转义过的。用jq,可以直接看中文。这点比较爽
如题。如果文件是"-test.log",是的你没看错。文件名前面有一个减号。如果你直接使用:rm -test.log,会报如下错误:
XML/HTML代码
- rm: invalid option -- 't'
- Try 'rm ./-test.log' to remove the file ‘-test.log’.
- Try 'rm --help' for more information.
毕竟。- 是有特殊意义的。那怎么删除呢?也简单:
XML/HTML代码
- rm -- -test.log
文件就这样被删除了。事实上,象这种"-"(减号、负号)开头的文件。因为它自带的特殊意义(linux下命令行的参数前缀),所以你用touch\vim等命令,其实都无法创建这样的文件。不信你试试"touch -test.log"。当然,你也是可以用touch -- -test.log来创建(其他类似)
比较简单的设置,就是利用 sshconfig 。
- 3、如果服务器需要通过跳板机登录(跳板机需要走本地网络代理)
-
- 首先配置跳板机ssh
-
- Host jumper
- HostName yyy.yyy.yyy.yyy # 跳板机IP,跳板机~/.ssh/authorized_keys需要配置ssh公钥
- User root
- ForwardAgent yes
- IdentityFile /Users/aslinwang/.ssh/id_ecdsa
- ProxyCommand corkscrew 127.0.0.1 12679 %h %p
- 然后通过跳板机访问服务器
-
- Host aslin
- HostName xxx.xxx.xxx.xxx # 远程服务器IP,~/.ssh/authorized_keys需要配置ssh公钥
- User root
- ForwardAgent yes
- IdentityFile /Users/aslinwang/.ssh/id_ecdsa
- ProxyCommand ssh jumper -W %h:%p 2> /dev/null
如果你不用 公钥,那可以尝试用sshpass (即,输密码式的登录):
XML/HTML代码
- Host aslin
- HostName xxx.xxx.xxx.xxx # 远程服务器IP,~/.ssh/authorized_keys需要配置ssh公钥
- User root
- ForwardAgent yes
- IdentityFile /Users/aslinwang/.ssh/id_ecdsa
- ProxyCommand sshpass -p [跳板机密码] ssh -p [跳板机端口] root@[跳板机IP] -W %h:%p 2> /dev/null
------EOF----
文中的aslinwang是上述网址文章中的用户,如果是你自己的,就是/Users/用户名/,相信能找到这里的人应该都明白
上一篇博客说了。我用vsc的ssh-remote的时候,30秒或者1分钟必断。错误信息一直就类似:
[04:30:38.608] "install" terminal command done
[04:30:38.609] Install terminal quit with output:
[04:31:18.258] SSH Resolver called for "ssh-remote+neatstudio.com", attempt 2
[04:31:18.258] SSH Resolver called for host: neatstudio.com
[04:31:18.259] Setting up SSH remote "neatstudio.com"
[04:31:18.259] Using commit id "f06011ac164ae4dc8e753a3fe7f9549844d15e35" and quality "stable" for server
[04:31:18.263] Running script with connection command: ssh -o ClearAllForwardings=true -o ConnectTimeout=15 neatstudio.com bash
[04:31:18.263] Install and start server if needed
[04:31:35.269] Connecting with SSH timed out
[04:31:35.269] TELEMETRY: {"eventName":"resolver","properties":{"outcome":"failure","reason":"Timeout"},"measures":{"resolveAttempts":2,"retries":1}}
[04:31:35.269] ------
重连后也是
[04:37:06.477] SSH Resolver called for "ssh-remote+neatstudio.com", attempt 12
[04:37:06.477] SSH Resolver called for host: neatstudio.com
[04:37:06.477] Setting up SSH remote "neatstudio.com"
[04:37:06.478] Using commit id "f06011ac164ae4dc8e753a3fe7f9549844d15e35" and quality "stable" for server
[04:37:06.479] Running script with connection command: ssh -o ClearAllForwardings=true -o ConnectTimeout=15 neatstudio.com bash
[04:37:06.480] Install and start server if needed
[04:37:21.515] > ssh: connect to host 123.176.103.247 port 22: Operation timed out
[04:37:21.515] Got some output, clearing connection timeout
[04:37:21.776] "install" terminal command done
[04:37:21.776] Install terminal quit with output: ssh: connect to host 123.176.103.247 port 22: Operation timed out
[04:37:21.776] Received install output: ssh: connect to host 123.176.103.247 port 22: Operation timed out
[04:37:21.777] The operation timed out
[04:37:21.777] TELEMETRY: {"eventName":"resolver","properties":{"outcome":"failure","reason":"OfflineError"},"measures":{"resolveAttempts":12,"retries":1}}
[04:37:21.777] ------
发了ticket给layerstack。他们测试也来没有这个问题。我开始以为是什么openfiles limit的问题。也打开到最大了。
期间调整了一下这个:echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p,因为开始有报inotify max error
直到他们给我发了一个ticket:
Thank you for your patience in this matter.
We have investigated the issue in detail and we are not able to recreate the issue from our end. We have checked the same from multiple locations and find out its working fine.
The reported issue seems to be related to your local ISP, so we suggest you to change the standard port (22) of SSH to some other non standard port like 2222 or 2244, in server and recheck the issue.
Please do have a check on our above suggestion and let us know if you still face any issues in accessing.
所以我就想了一下,直接把PORT改成了2222,2223,2244,然而仍然 失败,最后我用了一个超大端口,居然正常了