配置SS服务器(SSH服务器)通常涉及以下几个步骤
安装OpenSSH服务器
根据你的操作系统安装OpenSSH服务器:
- Linux(Ubuntu/Debian):
sudo apt update sudo apt install openssh-server
- Linux(CentOS/RHEL):
sudo yum update sudo yum install openssh-server
- macOS:
使用Homebrew安装:
brew install openssh
启动并启用开机启动:
sshd -i /etc/ssh/sshd_config sudo mkdir -p /var/run/sshd sudo chown -R sshd:sshd /var/run/sshd sudo systemctl enable sshd
配置SSH服务器
编辑配置文件 /etc/ssh/sshd_config:
sudo nano /etc/ssh/sshd_config
添加以下配置:
Port 22 ListenAddress 0...:22 PermitRootLogin yes PasswordAuthentication yes ChallengeResponseAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys X11Forwarding yes AllowTcpForwarding yes MaxAuthAttempts 10 PreAuthNumericCoding yes StreamLocalForwarding yes KerberosAuthentication no GSSAPIAuthentication no GSSAPIClientPrivateKeyFile /path/to/gssapi-key GSSAPIServerPrivateKeyFile /path/to/gssapi-server-key LogLevel INFO LogRotate yes
保存并退出,重启SSH服务:
sudo systemctl restart sshd
配置客户端
在本地计算机上安装OpenSSH客户端:
- Linux:
sudo apt install openssh-client
- macOS:
使用Homebrew安装:
brew install openssh-client
生成SSH键:
ssh-keygen -t rsa -b 4096
将私钥添加到~/.ssh/authorized_keys:
ssh-copy-id user@server_ip
编辑~/.ssh/config添加服务器配置:
nano ~/.ssh/config
Host server_ip HostName server_ip Port 22 User user PrivateKeyFile ~/.ssh/id_rsa
连接服务器
使用SSH命令连接:
ssh -p 22 user@server_ip
测试连接
确保能够成功登录并传输文件,如果有问题,检查配置文件或日志文件:
sudo tail -f /var/log/auth.log

如果没有特点说明,本站所有内容均由XVPN网络加速工具|覆盖科学上网、网络代理与节点管理,多平台客户端适配,满足不同网络环境下的连接需求原创,转载请注明出处!