add ssh config
This commit is contained in:
@@ -3,44 +3,52 @@
|
|||||||
- 아래의 방법으로 원하는 LAN카드의 MAC주소를 변경할 수 있다.
|
- 아래의 방법으로 원하는 LAN카드의 MAC주소를 변경할 수 있다.
|
||||||
- MAC주소가 변경되면 ISP 모뎀에서 새로운 기기로 인식하고 새로운 IP를 할당한다.
|
- MAC주소가 변경되면 ISP 모뎀에서 새로운 기기로 인식하고 새로운 IP를 할당한다.
|
||||||
|
|
||||||
```powershell
|
- Powershell:
|
||||||
# 현재 네트워크 어댑터 목록 확인
|
```powershell
|
||||||
Get-NetAdapter
|
# 현재 네트워크 어댑터 목록 확인
|
||||||
|
Get-NetAdapter
|
||||||
|
|
||||||
# MAC 주소 변경 (어댑터 이름과 원하는 MAC 주소 지정)
|
# MAC 주소 변경 (어댑터 이름과 원하는 MAC 주소 지정)
|
||||||
Set-NetAdapter -Name "이더넷" -MacAddress "00-11-22-33-44-55"
|
Set-NetAdapter -Name "이더넷" -MacAddress "00-11-22-33-44-55"
|
||||||
|
|
||||||
# 랜덤 MAC 주소 생성 및 설정
|
# 랜덤 MAC 주소 생성 및 설정
|
||||||
$randomMac = (0..5 | ForEach-Object { "{0:X2}" -f (Get-Random -Minimum 0 -Maximum 255) }) -join '-'
|
$randomMac = (0..5 | ForEach-Object { "{0:X2}" -f (Get-Random -Minimum 0 -Maximum 255) }) -join '-'
|
||||||
Set-NetAdapter -Name "이더넷" -MacAddress $randomMac
|
Set-NetAdapter -Name "이더넷" -MacAddress $randomMac
|
||||||
```
|
```
|
||||||
|
|
||||||
## WSL2에서 Windows SSH 접속하기
|
## ~~WSL2에서 Windows SSH 접속하기~~
|
||||||
|
|
||||||
WSL2의 명령어로 IP를 변경하기 위해 WSL2 -> Windows SSH 연결을 수립한다.
|
WSL2의 명령어로 IP를 변경하기 위해 WSL2 -> Windows SSH 연결을 수립한다.
|
||||||
|
|
||||||
Powershell (관리자로 실행)
|
- Powershell (관리자로 실행):
|
||||||
```powershell
|
```powershell
|
||||||
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
|
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
|
||||||
Start-Service sshd
|
Start-Service sshd
|
||||||
Set-Service -Name sshd -StartupType 'Automatic'
|
Set-Service -Name sshd -StartupType 'Automatic'
|
||||||
if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) {
|
if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) {
|
||||||
Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..."
|
Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..."
|
||||||
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
|
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
|
||||||
} else {
|
} else {
|
||||||
Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists."
|
Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists."
|
||||||
}
|
}
|
||||||
```
|
|
||||||
|
(Get-Content -Path "C:\ProgramData\ssh\sshd_config") |
|
||||||
|
ForEach-Object {$_ -replace "^#PubkeyAuthentication yes", "PubkeyAuthentication yes"} |
|
||||||
|
Set-Content -Path "C:\ProgramData\ssh\sshd_config"
|
||||||
|
```
|
||||||
|
Restart-Service sshd
|
||||||
|
|
||||||
Debian에서 바라보는 Windows의 IP는 다음과 같이 얻을 수 있다.
|
Debian에서 바라보는 Windows의 IP는 다음과 같이 얻을 수 있다.
|
||||||
```sh
|
- Debian bash:
|
||||||
ip route | grep default | awk '{print $3}'
|
```sh
|
||||||
# 172.17.112.1
|
ip route | grep default | awk '{print $3}'
|
||||||
```
|
# 172.17.112.1
|
||||||
|
```
|
||||||
|
|
||||||
ssh 계정에 접속받기 위해서는 그 윈도우 계정에 암호가 설정되어 있어야 한다.
|
ssh 계정에 접속받기 위해서는 그 윈도우 계정에 암호가 설정되어 있어야 한다.
|
||||||
|
|
||||||
Debian bash
|
- Debian bash:
|
||||||
```sh
|
```sh
|
||||||
ssh w@$(ip route | grep default | awk '{print $3}')
|
cat ~/.ssh/id_rsa.pub >> /mnt/c/Users/<YourUsername>/.ssh/authorized_keys
|
||||||
```
|
ssh w@$(ip route | grep default | awk '{print $3}')
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user