Configure ssh-config简化ssh , scp命令;Screen 后台运行命令

1. Configure .ssh/config简化ssh, scp命令

bash 复制代码
# Configure myServer
Host myServer
 HostName <ServerIP>
 User ubuntu
 IdentityFile /home/ubuntu/.ssh/<myServerKey>.pem

ssh 命令简化为. ssh myServer

bash 复制代码
ssh myServer

scp 命令简化为

bash 复制代码
scp -rp test.txt myServer:~/Downloads
  1. Linux 终端会话 screen 命令 让程序在后台运行

screen命令让ssh终端中命令在后台执行,即使当前ssh 会话断开,继续执行命令

bash 复制代码
1)查看当前screen列表 `screen -ls`

2)查看是否在screen中:`echo $STY` 查看当前是在 screen中还是终端里面 , 如果回显为空就在真·终端,否则会有 screen id 显示

3) 新建screen终端: 可以直接输入 screen; 推荐使用 `screen -R newName` 这样可以创建一个名为 newName 的screen终端, 并且 -R 会检查是否有同名的终端, 而 -S 则不会

4) 恢复detached screen: `screen -r [pid/name]`
    标准的用法: `screen -rd [pid/name]` , 这样先detach, 再attach,因为有时这个session是attached状态

5)当前终端界面下, `ctrl+a` 将进入等待命令的状态, 此时输入 d 会保存会话并后台运行
相关推荐
fengyehongWorld18 分钟前
Linux sudo命令
linux·运维·服务器
WG_1725 分钟前
Linux:缓冲区_glibc封装
linux·运维·服务器
番知了27 分钟前
Ubuntu 22.04 常用命令清单
linux·运维·ubuntu
旺仔Sec30 分钟前
2026年河北省职业院校技能大赛“网络系统管理”(高职组)网络构建样题
运维·服务器·网络
FF-Studio1 小时前
Ubuntu 24.04 磁盘爆满“灵异“事件:Btrfs, Snapper 与删不掉的空间
linux·运维·人工智能·ubuntu
爱尔兰极光1 小时前
计算机网络--网络层
运维·服务器·计算机网络
Neolnfra1 小时前
Xshell SSH 连接故障排查
运维·服务器·网络·ssh·xshell·运程连接
MonkeyKing_sunyuhua1 小时前
ubuntu22.04安装nginx
运维·windows·nginx
Joren的学习记录2 小时前
【Linux运维大神系列】Docker详解(二)
linux·运维·docker
Fortune_yangyang2 小时前
Docker 入门指南:从 “容器小白” 到快速上手
运维·docker·容器