SSH Setup (SSH Jump Host)

Semidragon·2023년 6월 21일
0

Ubuntu Basics

목록 보기
7/8

1. Problem

Trying to SSH to lab's servers at home using my mac, it was impossible to login/SSH/Ping to those servers as only local traffics were allowed.

Thus,today I am trying to access local servers via SKKU's(my university) opened servers uni.skku.edu via SSH JUMP HOST

#To B1
Local MAC -----> uni.skku.edu -----> b1 server
#TO Black
Local MAC -----> uni.skku.edu -----> black server

2. Solution

Solutions were driven from TecMint:
https://www.tecmint.com/access-linux-server-using-a-jump-host/
https://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/

2.1 Setup SSH Passwordless Login

Before setting up SSH Jump, I needed to make a passowrdless login environment, because info were all different per servers, and it would be a huge burden to type all of them everytime.

2.1.1 Create Authentication SSH-Keygen Keys

First, in the local client computer(mac), generate a pair of public keys using:

ssh-keygen -t rsa
#then press "ENTER" 4 times

2.1.2 Upload SSH Key to remote server

send a copy of the SSH key to the remote server using:

ssh-copy-id brian11hwang@uni.skku.edu -p 1398

This may not work at first due your mac not allowing SSH connections. Allow this via:
1. Select "System Preferences."
2. Click on "Sharing."
3. In the list on the left, check the box for "Remote Login."
Also, you may need to Setup Port Forwarding

2.1.3 Test SSH Passwordless Login

Next time I login, I can see that I could enter passwordlessly.

2.1.3 Do the same for uni -> b1 and black

As I would need paswordless access from uni to b1 and black, I repeated the steps once again.

3. Set Jump Host

Since I know all the hosts to jump, I will be using a Static Jump Host as below:
In ~/.ssh/config:

-q – This stands for quiet mode. It suppresses warnings and diagnostic messages.
-W – Requests that standard input and output on the client be forwarded to HOST on PORT over the secure channel.
%h – Specifies the host to connect to.
%p – Specified the port to connect to on the remote host.

Then, restart SSH Daemon via:

sudo systemctl restart ssh

4. Set xxh

xxh allows you to use your local ssh environment (plugins, themes etc) in you ssh environment.
First, install xxh and sshpass using:

brew install xxh
brew install hudochenkov/sshpass/sshpass

Then, simply use xxh instaed of ssh.

profile
Semidragon's network [CS undergrad @ Sungkyunkwan University | Networks + System @ CSI]

0개의 댓글