Monday, November 23, 2020

Unix/linux how to configure SSH proxy

Let say, server A B C

Server A cannot SSH to C directly

but B can SSH to C(192.168.66.29)

A can SSH to B(192.168.68.90)

Below are the setting

A .ssh]$ ls

config  id_rsa  id_rsa.pub  known_hosts

A .ssh]$ cat id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTGmoWURAB7OGw7T+r8stLraf5j8FdHNgE4SdVM0L8Zop6AIKcFhMa2suOeKzx+B4VXH54DT5vmV2X9iUrWQRqTODz5XaXX3Ck4VPnKawyOra8aLmqEfTS2Q4auKkb0rzXoEjNCu7YDttYjkiUpn/dZ2yw5TfXaKJrnIBqrFuxBh6sLHaYcRI+jzPPik1HIBnSv2rLVBtI6yF7mXom7stRt7dVe1CWvMCLLCalJMtgy+bx4wLbr61moAmSD0j/GTQWuek7/2fqpMEIMl4Y57B4T6sTSSsCJRs5SFxVQu/l908UjWTOhpjToJzltkmJNA2IovyoIBAwSFLabwb9+6PH useid@A

A .ssh]$


1- Update .ssh/authorized_keys on user1@192.168.68.80 with id_rsa.pub per above on hostA n B

2- Update .ssh/authorized_keys on user2@192.168.66.29 

3- Update per below on A

A ~]$ ls -l /home/openet/.ssh/config

-rwx------ 1 user2 user2 80 Sep 26 13:46 /home/user2/.ssh/config

A ]$ cat /home/openet/.ssh/config

Host 192.168.66.29

     ProxyCommand ssh -l user1 192.168.68.90 exec nc %h %p

A }$




No comments:

UNIX: How to print column nicely using printf

[user@hostfwnms1-oam tmp]# cat b.sh printf "%-26s %-19s %-8s %-8s %-s %-s\n" HOSTNAME IP PING SNMPWALK 0-ok 1-fail for i in `cat n...