type
status
date
slug
summary
tags
category
titleIcon
password
icon
insider
🎮
用于实验室使用受控(无sudo,无root,无docker,无apt,无代理)环境下,实现服务器间rsync同步数据,git代码管理(本机结合AI开发,远程pull使用),终端后台运行,绕开apt安装,ssh转发流量

服务器互连 - ssh

  • 主要用于后续rsync使用与流量转发

本机生成公私钥对

  • -t可选rsa,-C备注

远程写入公钥到认证文件

  • 将~/.ssh/id_ed25519.pub内容写入~/.ssh/authorized_keys下,占据一行
notion image

数据同步 - rsync

用途

  • 相比与下载到本地后再次上传其他服务器,少一次传输,可增量更新,且如果没有内网设备(靠内网穿透访问服务器),此方法速度较慢,连接不稳定
  • 服务器间通过rsync以内网速度传输数据

实践

  • -e后接ssh语句,用于修改端口(非默认22情况),指明私钥认证文件,也可以写在.ssh/config配置里
  • 目录顺序为from to
  • 如果结尾加/,那么不创建文件夹自身,而是将所有内容拷贝过去
  • 内网速度传输,不受校园网30M带宽限制
notion image
notion image
  • 另一台服务器上获取到数据(解压后)
notion image

代码同步与管理 - git bare

git远程地址

  • git只需将远程设置为ssh版本,其他正常使用
  • 只读下代码仓库不需要init加上bare(bare后才可以push到远程仓库)
notion image
  • 做完修改后直接服务器上pull即可

修改地址

  • 如果出现ip变动情况,可以在.git下config修改,如果ip变动频繁,参考ssh转发部分
notion image

绕开apt安装软件 - micromamba/pixi

用途

  • 如果没有sudo权限,也没有指定apt当前用户可用,就需要绕开apt进行安装
  • 但在作为最后兜底(last resort)的源码构建之前,还可以先尝试使用micromamba/pixi进行安装

micromamba

  • 演示micromamba使用,但更推荐pixi
notion image

安装fzf - 查找文件与命令行历史

  • fzf可以用于搜索文件,以及最重要的,ctrl + r搜索过往命令(不然也可以手动查看bash_history)
  • 先安装
notion image
  • 然后执行初始化后即可使用
notion image

pixi

  • 安装pixi
notion image
  • 使用pixi global install xxx,安装的包在~/.pixi/bin下
notion image

安装btop - 检测进程与CPU,内存磁盘等占用

notion image
notion image

安装nvtop - 监控显卡使用

notion image

SSH转发访问外网与本地git

用途

  • 通过RemoteForward转发服务器流量到本地(socks5h代理,DNS解析也会在代理服务器即本机完成),如使用TUN,可以直接访问外网(Google等),如使用代理,需结合ProxyChains
  • 通过RemoteForward转发端口到localhost:22进行git相关访问,避免动态IP影响git仓库配置
  • 通过一台设备autossh保持连接到多个服务器,使得多个服务器可以保持连通外网,且不计入校园网设备数

可用方式

  • 本机直接连接 - 本机配置转发即可
  • 通过其他设备连接 - 其他设备配置转发
  • 通过其他服务器连接 - 其他服务器配置转发
  • 需要保持连接 → autossh
  • 需要开机自启 → crontab (需要可以配置定时监控心跳,不存活时自启)
  • 目标服务器配置代理(bashrc)

实践

  • ssh进入另一台设备(不关机,用于仅联网跳板,TUN,选取较稳定节点),修改ssh配置(多服务器可同一端口,便于设置)
notion image
  • 使用如下autossh连接,ctrl + b + d,detach tmux即可
notion image
  • 配置服务器使用代理,可bashrc
  • 也可使用vscode填入,ping不会生效
notion image
  • 在主力设备上以如下配置连接(可以让socks5h走同一设备,但后台任务如果需要联网,需要保持不关机,可分离设备实现),观察到转发端口详情,第一为git转发,第二为网络
notion image
  • 测试pixi安装 → 网络连接✔
  • 测试curl Google → 外网连接✔
  • 测试git → 成功访问本地git仓库✔
notion image
notion image
  • git clone
notion image
 
 
  • 在服务器间使用
  • 安装autossh
notion image
notion image
  • 测试ssh
notion image
  • 写ssh配置
notion image
 
  • 查看autossh位置配置crontab
notion image
notion image
  • 测试连通,可以上网,不能外网,确实是服务器连通
notion image
 
 

其他杂项

tmux后台运行

  • tmux开启的终端不会在ssh后退出
  • 执行tmux开启终端后通过ctrl + b,再按下d(detach)
  • tmux attach回到最近detach的终端
  • tmux list-sessions列出所有可复用的终端

pip镜像

指定镜像

配置镜像

数据集划分常用管道运算

  • ls -1 | grep Case | wc -l 统计包含Case名称的文件数目
  • ls -1 | grep Case | head -n 666 前666项划分至train
notion image
  • tail -n +667,跳至第667项开始,选取167项划分至valid(无727Case)
notion image

pip本地安装

  • pip install -e .(源码仓库文件夹)

使用swanlab看实验进度与效果

  • 与tensorboard同性质的在线监控面板(可自部署,可离线后自行同步线上)
  • 可以阅读文档实现,或省事地,让参考使用了swanlab仓库的实现方式修改自己现有项目
  • 可以根据数据生成表格,比较方便,可以监控服务器的资源信息,日志,实验环境与实验配置
notion image
 
 
 
 
理解Git原理MiniMind学习流程
Loading...
2024-2026CamelliaV.

CamelliaV | Java;前端;AI;ACGN;