Config on Remote Development 用服务器写项目

Start to develop on server so some config to easy the workload is pretty important.


ssh

先配ssh免密登录,第一次需要输入服务器密码

1
2
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/key.pub root@xxx.xxx.xx.xx

再配config,~/.ssh/config中加入

1
2
3
4
5
Host server
Hostname xxx.xxx.xx.xx
User root
Port xxxx
IdentityFile ~/.ssh/key

使用:

1
ssh server

挂载目录

之前已经配好了ssh

1
sshfs server:/path/to/folder /path/to/mount/point

其他

通过中间主机建立SSH连接

1
ssh -t reachable_host ssh unreachable_host

创建到目标主机的持久化连接

1
ssh -MNf <user>@<host>

没有SSH-COPY-ID命令的主机将你的SSH公钥复制到服务器

1
cat ~/.ssh/id_rsa.pub | ssh user@machine “mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys”

继续SCP大文件(需要两遍都有rsync)

1
2
3
rsync –partial –progress –rsh=ssh $file_source $user@$host:$destination_file
rsync –partial –progress –rsh=ssh $file_source $user@$host:$destination_file local -> remote
rsync –partial –progress –rsh=ssh $user@$host:$remote_file $destination_file remote -> local

保持SSH会话永久打开(切换wifi时不会断开)

1
autossh -M50000 -t server.example.com 'screen -raAd mysession'

其他服务器常用命令备忘

查看基础信息

1
uname -a

Config on Remote Development 用服务器写项目

https://nyte-bk201.github.io/2020/01/14/Config on Remote Developmen/

Author

nyte

Posted on

2020-01-15

Updated on

2021-06-10

Licensed under