아따 많이도 찾아봤었네 -_-

집에는 라즈베리 하나 켜놓고 회사에 켠 녀석을 집으로 SSH 접속하게 하고

집에서는 내부 아이피로 역으로 접속할수 있는 시스템을 만들려고 하는 중

 

[링크 : https://manpages.ubuntu.com/manpages/jammy/man1/autossh.1.html]

[링크 : https://lstm.tistory.com/10]

[링크 : https://m.clien.net/service/board/cm_linux/4344761]

[링크 : https://sangwonyoon.tistory.com/m/entry/Autossh로-SSH-연결-유지하기]

 

2018.05.14 - [프로그램 사용/ssh scp sftp] - reverse SSH

2021.01.03 - [프로그램 사용/ssh scp sftp] - reverse ssh

 

 

-------------------

2026.05.13

아래 링크의 옵션 참조했음

[링크 : https://donotlimityourself.tistory.com/33[

 

private(회사)

원격지에 2222 포트로 현재 pc의 22번 포트를 돌린다~ 라는 의미 인듯한데

그래서 listen에 추가로 포트가 열리지도 않았고, 정상적으로 실행이 되는 건가 보다.

$ ssh minimonk@집SSH도메인 -p 8022 -f -N -T -R 2222:localhost:22
minimonk@집SSH도메인's password: 
$ ps -ef | grep ssh
root         900       1  0  5월12 ?      00:00:00 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
root        2298     900  0  5월12 ?      00:00:00 sshd: minimonk [priv]
minimonk    2385    2298  0  5월12 ?      00:05:27 sshd: minimonk@pts/0
root        5656     900  0  5월12 ?      00:00:00 sshd: minimonk [priv]
minimonk    5735    5656  0  5월12 ?      00:00:00 sshd: minimonk@pts/7
minimonk   10717       1  0 09:58 ?        00:00:00 ssh minimonk@집SSH도메인 -p 8022 -f -N -T -R 2222:localhost:22
minimonk   10719    5736  0 09:58 pts/7    00:00:00 grep --color=auto ssh

$ netstat -tnlp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:39557         0.0.0.0:*               LISTEN      3128/language_serve 
tcp        0      0 127.0.0.1:5803          0.0.0.0:*               LISTEN      5350/llama-server   
tcp        0      0 127.0.0.1:38605         0.0.0.0:*               LISTEN      3128/language_serve 
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:6012          0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:45837         0.0.0.0:*               LISTEN      6184/language_serve 
tcp        0      0 0.0.0.0:7860            0.0.0.0:*               LISTEN      5584/venv/bin/pytho 
tcp        0      0 127.0.0.1:36141         0.0.0.0:*               LISTEN      6184/language_serve 
tcp        0      0 127.0.0.1:36197         0.0.0.0:*               LISTEN      6184/language_serve 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:44747         0.0.0.0:*               LISTEN      3016/antigravity    
tcp        0      0 127.0.0.1:35159         0.0.0.0:*               LISTEN      6061/exe            
tcp        0      0 127.0.0.1:34279         0.0.0.0:*               LISTEN      3016/antigravity    
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -                   
tcp6       0      0 :::5900                 :::*                    LISTEN      1502/gnome-remote-d 
tcp6       0      0 ::1:631                 :::*                    LISTEN      -                   
tcp6       0      0 :::8080                 :::*                    LISTEN      5256/./llama-swap   
tcp6       0      0 :::22                   :::*                    LISTEN      -                   
tcp6       0      0 ::1:6010                :::*                    LISTEN      -                   
tcp6       0      0 ::1:6012                :::*                    LISTEN      -                   
tcp6       0      0 :::3389                 :::*                    LISTEN      1502/gnome-remote-d 

 

public(내 집)

접속전
$ netstat -tnlp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -                   
tcp6       0      0 :::22                   :::*                    LISTEN      -  

접속후
$ netstat -tnlp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:2222          0.0.0.0:*               LISTEN      -                   
tcp6       0      0 :::22                   :::*                    LISTEN      -                   
tcp6       0      0 ::1:2222                :::*                    LISTEN      -      

 

SSH 옵션을 보면 -fNTR 에서  -f이 백그라운드로 뜨게 하느것이고

NT는 터미널 관련, 명령 실행 관련

R은 원격지 포트에 내껄 붙인다는 의미

역시 NTR은 좋은것이여... (응?)

     -f      Requests ssh to go to background just before command execution.
             This is useful if ssh is going to ask for passwords or
             passphrases, but the user wants it in the background.  This im‐
             plies -n.  The recommended way to start X11 programs at a remote
             site is with something like ssh -f host xterm.

             If the ExitOnForwardFailure configuration option is set to “yes”,
             then a client started with -f will wait for all remote port for‐
             wards to be successfully established before placing itself in the
             background.  Refer to the description of ForkAfterAuthentication
             in ssh_config(5) for details.


     -N      Do not execute a remote command.  This is useful for just for‐
             warding ports.  Refer to the description of SessionType in
             ssh_config(5) for details.

     -T      Disable pseudo-terminal allocation.

     -R [bind_address:]port:host:hostport
     -R [bind_address:]port:local_socket
     -R remote_socket:host:hostport
     -R remote_socket:local_socket
     -R [bind_address:]port
             Specifies that connections to the given TCP port or Unix socket
             on the remote (server) host are to be forwarded to the local
             side.

 

이제 autossh를 설치하고

$ sudo apt-get install autossh
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  autossh
0 upgraded, 1 newly installed, 0 to remove and 47 not upgraded.
Need to get 29.2 kB of archives.
After this operation, 89.1 kB of additional disk space will be used.
Get:1 http://kr.archive.ubuntu.com/ubuntu jammy/universe amd64 autossh amd64 1.4g-1 [29.2 kB]
Fetched 29.2 kB in 0s (217 kB/s)   
Selecting previously unselected package autossh.
(Reading database ... 322586 files and directories currently installed.)
Preparing to unpack .../autossh_1.4g-1_amd64.deb ...
Unpacking autossh (1.4g-1) ...
Setting up autossh (1.4g-1) ...
Processing triggers for man-db (2.10.2-1) ...

 

 public 쪽에 로그인이 되도록 키를 복사하려는데 안되네 -_-???

아무튼 키를 생성하고 해주면 끝

$ ssh-copy-id -p 8022 minimonk@집SSH도메인
/usr/bin/ssh-copy-id: ERROR: No identities found

$ ssh-keygen

 

-f 를 넣으면 키를 넣어줘도 로그인이 안되서 일단 빼고 하니 되긴한데..

$ autossh -M -0 -o "ServerAliveinterval 30" -o "ServerAliveCountMax 3" -T -R 2222:localhost:22 minimonk@집SSH도메인 -p 2022

[링크 : https://sangwonyoon.tistory.com/entry/Autossh로-SSH-연결-유지하기]

 

autossh가 죽으면 어쩌지 싶어서 데몬으로 된 거 없나 찾아 봐야 할 듯.

[링크 : https://tecadmin.net/autossh-persistent-ssh-connections/]

 

 

+

여러 번의 인자를 사용하면 복수의 포트를 포워딩 할 수 있다.

ssh remote-host -L 8822:REMOTE_IP_1:22 -L 9922:REMOTE_IP_2:22

[링크 : https://stackoverflow.com/questions/29936948/ssh-l-forward-multiple-ports]

 

+

아래를 public 쪽 sshd_config 에 설정해주고 sshd를 재기동하고

$ cat /etc/ssh/sshd_config
# GatewayPorts no
GatewayPorts yes
$ sudo systemctl restart sshd

 

2222 대신 0.0.0.0:2222 라고 입력하고 실행하면

$ ssh minimonk@집SSH도메인 -p 8022 -f -N -T -R 0.0.0.0:2222:localhost:22

 

localhost로 되어있던걸

$ netstat -tnlp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:2222          0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      -
tcp6       0      0 :::22                   :::*                    LISTEN      -
tcp6       0      0 ::1:2222                :::*                    LISTEN      -
tcp6       0      0 ::1:6010                :::*                    LISTEN      -

 

0.0.0.0 으로 바꾸어서 public 서버의 서비스 인것 처럼 붙일수도 있다.

$ netstat -tnlp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:2222            0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      -
tcp6       0      0 :::22                   :::*                    LISTEN      -
tcp6       0      0 :::2222                 :::*                    LISTEN      -
tcp6       0      0 ::1:6010                :::*                    LISTEN      -

'프로그램 사용 > ssh scp sftp' 카테고리의 다른 글

ssh -t  (0) 2025.09.08
ssh-copy-id  (0) 2025.04.18
ssh socks proxy  (0) 2024.07.22
ssh ecdsa 미지원(ubuntu 22.04)  (0) 2023.05.30
ubuntu ssh x11 forwarding시 gnome 화면 끌어오기  (0) 2022.07.11
Posted by 구차니

ssh를 통해 iperf3 -s 옵션으로 실행 했는데

결과 내용이 ssh 터미널을 통해 나오지 않아서 3 ai들에게 물어보니

cluade가 알려줌. 그 와중에 gemini는 도움이 안되고 chatGPT는 파일로 떨구라고 알려줌.. (야이 -_-)

 

아무튼 -t 라는 옵션을 주면 잘 나온다. 신기하네..

     -T      Disable pseudo-terminal allocation.

     -t      Force pseudo-terminal allocation.  This can be used to execute
             arbitrary screen-based programs on a remote machine, which can be
             very useful, e.g. when implementing menu services.  Multiple -t
             options force tty allocation, even if ssh has no local tty.

 

iperf3 가 취소되어 종료되고 나서 한번에 iperf3 서버쪽 결과가 나옴. 일종의 버퍼링 상태인가..

ssh localhost "iperf3 -s"  
  iperf3 -c localhost
Connecting to host localhost, port 5201
[  5] local 127.0.0.1 port 43416 connected to 127.0.0.1 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  5.94 GBytes  51.0 Gbits/sec    0   1.31 MBytes       
[  5]   1.00-2.00   sec  6.09 GBytes  52.3 Gbits/sec    0   1.31 MBytes       
[  5]   2.00-3.00   sec  5.79 GBytes  49.7 Gbits/sec    0   1.31 MBytes       
^C[  5]   3.00-3.37   sec  2.26 GBytes  51.8 Gbits/sec    0   1.31 MBytes 
iperf3: the client has terminated
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 127.0.0.1, port 43412
[  5] local 127.0.0.1 port 5201 connected to 127.0.0.1 port 43416
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  5.72 GBytes  49.1 Gbits/sec                  
[  5]   1.00-2.00   sec  6.09 GBytes  52.3 Gbits/sec                  
[  5]   2.00-3.00   sec  5.81 GBytes  49.9 Gbits/sec                  
[  5]   2.00-3.00   sec  5.81 GBytes  49.9 Gbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-3.00   sec  20.1 GBytes  57.5 Gbits/sec                  receiver
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-3.37   sec  20.1 GBytes  51.1 Gbits/sec    0             sender
[  5]   0.00-3.37   sec  0.00 Bytes  0.00 bits/sec                  receiver
iperf3: interrupt - the client has terminated

 

그 와중에 iperf3 -s 를 실행한 ssh를 종료하면 PPID 1번으로 붙어 버린다. 야이 -_-

마치 -D / --daemon 옵션을 주고 한 것 같아지냐

$ ps -ef | grep iperf3
falinux   811482       1  2 12:12 ?        00:00:02 iperf3 -s

 

딱이네.. 머지? 터미널이 없으면 자동으로 daemon 모드로 작동하나?

$ iperf3 -D -s
$ ps -ef | grep iperf3
user   811482       1  1 12:12 ?        00:00:02 iperf3 -s

 

아무튼 대망의(?) -t 옵션. 잘 된다.

ssh -t localhost "iperf3 -s"
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
 
Accepted connection from 127.0.0.1, port 60822
[  5] local 127.0.0.1 port 5201 connected to 127.0.0.1 port 60830
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  5.48 GBytes  47.0 Gbits/sec                  
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  5.48 GBytes  47.0 Gbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  7.60 GBytes  65.3 Gbits/sec                  receiver
iperf3: the client has terminated
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
iperf3 -c localhost
Connecting to host localhost, port 5201
[  5] local 127.0.0.1 port 60830 connected to 127.0.0.1 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  5.70 GBytes  49.0 Gbits/sec    0   1.25 MBytes       
^C[  5]   1.00-1.32   sec  1.90 GBytes  50.5 Gbits/sec    0   1.25 MBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-1.32   sec  7.60 GBytes  49.4 Gbits/sec    0             sender
[  5]   0.00-1.32   sec  0.00 Bytes  0.00 bits/sec                  receiver
iperf3: interrupt - the client has terminated

[링크 : https://stackoverflow.com/questions/42505339/why-use-t-with-ssh]

'프로그램 사용 > ssh scp sftp' 카테고리의 다른 글

리버스 ssh + autossh  (0) 2026.05.11
ssh-copy-id  (0) 2025.04.18
ssh socks proxy  (0) 2024.07.22
ssh ecdsa 미지원(ubuntu 22.04)  (0) 2023.05.30
ubuntu ssh x11 forwarding시 gnome 화면 끌어오기  (0) 2022.07.11
Posted by 구차니

와!! 이런 개꿀 명령어가?!?!?

직접 키 복사해서 넣어도 되지만 한번만 접속하면 알아서 복사해주니 개 꿀!

 

ssh-copy-id [-i [identity_file]] [user@]machine

[링크 : https://linux.die.net/man/1/ssh-copy-id]

 

[링크 : https://itzone.tistory.com/694]

'프로그램 사용 > ssh scp sftp' 카테고리의 다른 글

리버스 ssh + autossh  (0) 2026.05.11
ssh -t  (0) 2025.09.08
ssh socks proxy  (0) 2024.07.22
ssh ecdsa 미지원(ubuntu 22.04)  (0) 2023.05.30
ubuntu ssh x11 forwarding시 gnome 화면 끌어오기  (0) 2022.07.11
Posted by 구차니

예전에 해봤는데 안되길래 포기했던 녀석들..

이제는 시간이 지났으니 잘 되려나?

 

ssh -D

[링크 : https://superuser.com/questions/408031/differences-between-ssh-l-to-d]

 

wget은 socks proxy 미지원,curl 사용 필요

[링크 : https://askubuntu.com/questions/1327783/can-you-set-socks5-proxy-from-linux-command-line]

 

--proxy-server="socks5://myproxy:8080"

[링크 : https://www.chromium.org/developers/design-documents/network-stack/socks-proxy/]

 

[링크 : https://thesafety.us/proxy-setup-chrome-windows]

[링크 : https://datawookie.dev/blog/2023/12/ssh-tunnel-dynamic-port-forwarding/]

'프로그램 사용 > ssh scp sftp' 카테고리의 다른 글

ssh -t  (0) 2025.09.08
ssh-copy-id  (0) 2025.04.18
ssh ecdsa 미지원(ubuntu 22.04)  (0) 2023.05.30
ubuntu ssh x11 forwarding시 gnome 화면 끌어오기  (0) 2022.07.11
ssh 슈도 터미널 실행  (0) 2022.04.25
Posted by 구차니

ubuntu 22.04로 올렸더니 git에서 받으려고 시도했으나 실패해서

옆자리 동료에서 물어보니 ssh 보안관련 문제라고

 

그래서 추가로 검색해보니 SSL 에서 구버전 암호화 deprecate 시키듯이

SSH 에서도 ed25519 를 구버전 암호화로 사용을 막도록 기본값을 변경해서 생긴 문제인 듯.

The RSA SHA-1 hash algorithm is being quickly deprecated across operating systems and SSH clients because of various security vulnerabilities, with many of these technologies now outright denying the use of this algorithm.

It seems this has happened for the ssh client in Ubuntu 22.04. The RSA public-private key pair is considered not safe any more.

Solution
Use a more modern and secure type of key such as ed25519. Generate a new key pair in your Ubuntu 22.04 computer with this command:

ssh-keygen -t ed25519 -C "colin@colin-desktop"

[링크 : https://askubuntu.com/questions/1409105/ubuntu-22-04-ssh-the-rsa-key-isnt-working-since-upgrading-from-20-04]

[링크 : https://songs-family.tistory.com/entry/장애이슈-SSH-키-인증-방식-변경ssh-rsa-ecdsa-에-따른-서비스-장애]

 

EdDSA는 Edwards-curve 디지털 서영 알고리즘의 약자고

Ed25519는 SHA-512와 curve25519를 사용했다는데

Edwards-curve Digital Signature Algorithm (EdDSA)
Ed25519 is the EdDSA signature scheme using SHA-512 (SHA-2) and Curve25519[2] where

[링크 : https://en.wikipedia.org/wiki/EdDSA]

 

curve25519는 128bit 암호화를 제공해서 잘린건가?

In cryptography, Curve25519 is an elliptic curve used in elliptic-curve cryptography (ECC) offering 128 bits of security (256-bit key size) and designed for use with the elliptic curve Diffie–Hellman (ECDH) key agreement scheme. 

[링크 : https://en.wikipedia.org/wiki/Curve25519]

Posted by 구차니

20.10 에서 테스트 완료.

18.04 에서도 해봐야 하려나? (세션 로그아웃 시키기 귀찮은디..)

 

$ sudo vi /etc/gdm3/custom.conf
# GDM configuration storage
#
# See /usr/share/gdm/gdm.schemas for a list of available options.

[daemon]
# Uncoment the line below to force the login screen to use Xorg
WaylandEnable=false

# Enabling automatic login
#  AutomaticLoginEnable = true
#  AutomaticLogin = user1

# Enabling timed login
#  TimedLoginEnable = true
#  TimedLogin = user1
#  TimedLoginDelay = 10

AutomaticLoginEnable=True
AutomaticLogin=falinux

[security]

[xdmcp]

[chooser]

[debug]
# Uncomment the line below to turn on debugging
# More verbose logs
# Additionally lets the X server dump core if it crashes
#Enable=true


[링크 : https://www.answertopia.com/ubuntu/displaying-ubuntu-applications-remotely-x11-forwarding/]

Posted by 구차니

ssh를 통해 원격명령어 실행하려는데 watch의 경우 실행이 되지 않아 찾아보니

-t 옵션을 주어 pseudo-tty 할당하도록 하면 실행이 된다.

 

ssh -t

[링크 : https://stackoverflow.com/questions/47936491/using-watch-with-ssh]

Posted by 구차니

호스트의 키가 변경되면 ssh 로그인시 경고를 날리는데

-y 같이 해당 옵션을 무조건 yes로 무시하는게 없나 찾아보는 중

$ ssh 192.168.53.144
The authenticity of host '192.168.53.144 (192.168.53.144)' can't be established.
ECDSA key fingerprint is SHA256:
Are you sure you want to continue connecting (yes/no)?

 

개인적으로는 옵션으로 처리가능한게 깔끔해서 좋음.

$ ssh 192.168.53.144 -o StrictHostKeyChecking=no
Warning: Permanently added '192.168.53.144' (ECDSA) to the list of known hosts.
pi@192.168.53.144's password:

[링크 : https://info-lab.tistory.com/254]

Posted by 구차니

아.. 설정은 가능하구나.

 

$ sudo vim /etc/sshd_config
#Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem sftp internal-sftp

[링크 : https://techglimpse.com/allow-sftp-disallow-ssh-ubuntu/]

'프로그램 사용 > ssh scp sftp' 카테고리의 다른 글

ssh 슈도 터미널 실행  (0) 2022.04.25
ssh Are you sure you want to continue connecting (yes/no)?  (0) 2022.04.25
ssh 압축전송하기  (0) 2021.12.14
ssh 원격 명령어 실행  (0) 2021.09.29
reverse ssh  (0) 2021.01.03
Posted by 구차니

거창할 것 없이 -C 옵션 하나 주면 끝! 아쉽게도 압축레벨을 정할 순 없다.

Connecting with compression
A SSH tunnel does not only have the advantage that nobody can listen in on your transfers, but also another neat feature of SSH…. compression. To add compression to your connection just add a -C to the command which you use to connect with.

ssh -C user@server.com -L 5901:192.168.0.10:5901

[링크 : https://www.axllent.org/docs/ssh-tunnels/]

 

rtl-sdr 3.2MSPS로 전송받는데 압축하고 / 안하고의 차이가 상당히 크게 나온다.

운이 좋게도 압축이 잘 되는 데이터 인 듯?

'프로그램 사용 > ssh scp sftp' 카테고리의 다른 글

ssh Are you sure you want to continue connecting (yes/no)?  (0) 2022.04.25
sshd 에서 ssh 로그인 끄고 sftp만 허용하기  (0) 2022.04.01
ssh 원격 명령어 실행  (0) 2021.09.29
reverse ssh  (0) 2021.01.03
ssh blowfish  (0) 2019.09.24
Posted by 구차니