Ubuntu SSH命令行使用技巧包括:
sudo apt update && sudo apt install openssh-server
。sudo systemctl start ssh
和 sudo systemctl status ssh
。/etc/ssh/sshd_config
文件,例如添加 Port 2222
然后重啟SSH服務:sudo systemctl restart ssh
。ssh username@ip_address
。ssh -p port_number username@ip_address
。ssh-keygen -t rsa
,上傳公鑰到遠程服務器:ssh-copy-id username@ip_address
。使用 scp
進行安全的文件傳輸:
scp /path/to/local/file username@ip_address:/path/to/remote/destination
。scp username@ip_address:/path/to/remote/file /path/to/local/destination
。斷開SSH連接:exit
。
/etc/ssh/sshd_config
中設置 PermitRootLogin no
。PubkeyAuthentication yes
和 PasswordAuthentication no
。ufw
允許SSH流量:sudo ufw allow ssh
。sudo systemctl status ssh
。通過以上技巧,可以更高效和安全地使用Ubuntu的SSH命令行功能。