ssh 代理

配置

StrictHostKeyChecking no
HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa

ssh sock5代理配置方式

Host p800 
HostName 10.46.222.142
ProxyCommand nc -X 5 -x 10.93.234.25:8989 %h %p  
Port 22
User shikejing (远程账户)

sock5代理程序

https://github.com/ginuerzh/gost
./gost -L=socks://:8989

ssh 跳板机代理配置方式

Host test
    HostName 10.45.150.212
    User shikejing  (远程账户)
    ProxyJump proxy
Host proxy
    HostName 58.34.179.90
    Port 8023
    User isa 

Host sock10 
HostName 10.45.150.213
ProxyCommand nc -X 5 -x 10.93.234.25:8989 %h %p  
Port 22
User shikejing 


Host sock10d
HostName 10.45.150.213
ProxyJump sock10
Port 2200
User shikejing

开始sshd

vim /etc/ssh/sshd_config  (配置端口即可)
service ssh restart

不同账户登录

账户A
copy ~/.ssh/id_rsa.pub  到远端账户B  ~/.ssh/authorized_keys

账户A机器下,用账户b远程登录
ssh b@machine_b -p port

反向代理 (本地登录远程服务器,只要远程服务器能连公网)

# MA 个人电脑   MB 公网ecs  MC 远程服务器 
# MC:cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys
# MC:ssh -fN -R 3389:localhost:2200 ubuntu@117.50.69.40
# MB: id_ed25519.pub to MC
# MB:ssh -p 3389 root@localhost
# MA: id_ed25519.pub to MB MC
Host ubuntu
HostName 117.50.69.40
User ubuntu

Host h20
    HostName localhost
    User root
    Port 3389
    ProxyCommand ssh -W %h:%p ubuntu
posted @ 2025-03-21 17:42  恰逢其时40  阅读(59)  评论(0)    收藏  举报