Linux/terminal

How to connect to the server from the client, set to alias.

Naranjito 2022. 3. 15. 11:30
Steps
1. Make the key-to connect to the server, avoid to type id, pw everytime.
2. Connect to the server.
2-1. Tip : Easy way to connect.
3. Restart bashrc if pipe broken.

 

1. Make the key-to connect to the server, avoid to type id, pw everytime.

  • ssh-keygen

Generate the key.

ssh-keygen -t rsa

>>>

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/joohyunyoon/.ssh/id_rsa):
Created directory '/Users/joohyunyoon/.ssh'.

...

|Ooo   E          |
+----[SHA256]-----+

 

And check the generated key.

id_rsa : private key

id_rsa.pub : public key

cd ~/.ssh
ls -la

>>>

total 16
drwx------   4 joohyunyoon  staff   128 Mar 14 10:59 .
drwxr-x---+ 15 joohyunyoon  staff   480 Mar 14 10:59 ..
-rw-------   1 joohyunyoon  staff  2635 Mar 14 10:59 id_rsa #<----
-rw-r--r--   1 joohyunyoon  staff   592 Mar 14 10:59 id_rsa.pub #<----

 

And check the content of key.

cat id_rsa.pub

>>>

ssh-rsa AAAAB3NzaC1

...

 

2. Connect to the server.

Change the directory first.

cd ~/.ssh

And then connect to the server.

ssh naranja@xxx.xx.x.xx

>>>

Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-90-generic x86_64)

...
ssh naranja@cpu-server1

>>>

The authenticity of host 'cpu-server1 (172.30.1.44)' can't be established.

...

 

2-1. Tip : Easy way to connect.

Easy way to access setting with alias. Then I can access the server with alias name only.

$ vi .bashrc

>>>

alias illunex="ssh illunex-cpu-server1 -Lxxxx:xxx.xx.x.xx:xxxx -N"

 

3. Restart bashrc if pipe broken.

packet_write_wait: Connection to xxx.xx.xxx.xxx port xxxx: Broken pipe
packet_write_wait: Connection to UNKNOWN port xxxxx: Broken pipe

>>>

$ source ~/.bashrc
$ illunex

 

'Linux > terminal' 카테고리의 다른 글

Install pyenv-virtualenv on mac  (0) 2022.03.31
How to add new server  (0) 2022.03.31
shell, bash  (0) 2022.03.15
$, grep  (0) 2022.01.03
move folder, rmdir, rm -r, rm -rf ., touch, find, cat, -p  (0) 2021.01.26