文章目录
- Symbols annotation
- Windows commands
- Linux commands
- Actions for sshd configuration on linux
- Actions for sshd access on **LAN remote windows terminal**
- Actions for sshd access on **local windows terminal**
- Actions for sshd access on **frp server remote windows terminal**
- About sshd server configuration
- References
Symbols annotation
$WindowsLocaIP # Windows local ip
$ForwardLocalPort # Windows forworad port for ssh access
$LinuxUsername # Linux user name
$LinuxSubnetIP # Linux subnet ip
$LinuxListeningPort # Linux listening port for ssh access
$LinuxPassword # Linux login password
$FrpServerSite # Frp server site
$FrpIP # Frp server ip
$FrpPort # Frp server forward port
Windows commands
netsh advfirewall firewall add rule name="Open Port $ForwardLocalPort for WSL Linux" dir=in action=allow protocol=TCP localport=$ForwardLocalPort
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=$ForwardLocalPort connectaddress=$LinuxSubnetIP connectport=$LinuxListeningPort
netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=$ForwardLocalPort
netsh interface portproxy show all
netsh int portproxy reset all
wsl -u username
Linux commands
passwd #password
exit
Actions for sshd configuration on linux
Check ip:
hostname
hostname -i
hostname -I
ifconfig
Open sshd_config:
sudo apt install openssh-server
cd /etc/ssh/
sudo vim sshd_config
$LinuxPassword
Add:
ListenAddress 0.0.0.0
Uncomment and modify:
Port $LinuxListeningPort
Start server and check status:
sudo service ssh start
service ssh status
Enable autostart for ssh server:
sudo systemctl enable ssh
Actions for sshd access on LAN remote windows terminal
Port forward configuration
netsh advfirewall firewall add rule name="Open Port $ForwardLocalPort for WSL Linux" dir=in action=allow protocol=TCP localport=$ForwardLocalPort
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=$ForwardLocalPort connectaddress=$LinuxSubnetIP connectport=$LinuxListeningPort
SSH access (Linux username: $LinuxUsername, windows ip: $WindowsLocaIP):
ssh -p $ForwardLocalPort $LinuxUsername@$WindowsLocaIP
yes
$LinuxPassword #WSL passwords
Actions for sshd access on local windows terminal
SSH access with Linux subnet ip (Linux username: $LinuxUsername, Linux ip: $LinuxSubnetIP):
ssh $LinuxUsername@$LinuxSubnetIP
yes
$LinuxPassword #WSL passwords
Actions for sshd access on frp server remote windows terminal
Create frp Tunnel using sakura frp (local ip: $WindowsLocaIP, forward local port: $ForwardLocalPort):
2024/07/28 15:06:31 I Tunnel/MyTunnel [53/455749/0c9c] 限速已更新: 10 Mibit/s
Tunnel/MyTunnel TCP 类型隧道启动成功
Tunnel/MyTunnel 使用 [$FrpServerSite:$FrpPort] 来连接到你的隧道
Tunnel/MyTunnel 或使用 IP 地址连接(不推荐): [$FrpIP:$FrpPort]
SSH access with frp ip (Linux username: $LinuxUsername, frp server ip: $FrpIP):
ssh -p $FrpPort $LinuxUsername@$FrpIP
yes
$LinuxPassword #WSL passwords
About sshd server configuration
For windows system, the configuration of sshd_config
file is restricted according to documentation at sshd_config · PowerShell.
Specifically for AuthenticationMethods option, the options have a large scale reduction compared with Linux Man Pages.
Available authentication methods are password
and publickey
.
So one can’t set AuthenticationMethods
to none
for windows hosts which has no passwords to log in, thus making it a necessity to create a password for the system.
To establish a password-less ssh connection, key-based authentication with windows hosts, one must put the publick-key file content into the administrators_authorized_keys under C:\ProgramData\ssh
.