You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 16.04下.ssh/config有效字段及自定义配置问题咨询

Hey there! Let's tackle your SSH config questions step by step, since you're already up and running with basic entries on Ubuntu 16.04:

SSH Config FAQs for Ubuntu 16.04

1. What are the valid fields in ~/.ssh/config?

There are dozens of valid configuration options, but here are the most useful ones (including the basics you're already using):

  • Host: The alias you use to initiate the connection (e.g., Host my-server lets you run ssh my-server instead of the full command)
  • HostName: The actual server hostname or IP address
  • Port: The SSH port number (defaults to 22 if omitted)
  • User: The remote account username
  • IdentityFile: Path to your private key file for public key auth
  • ForwardAgent: Enables forwarding your local SSH agent to the remote server (yes/no)
  • StrictHostKeyChecking: Controls how SSH handles unknown host keys (options: yes, ask, no)
  • ServerAliveInterval: Sends periodic keep-alive packets to prevent idle connections from dropping
  • Compression: Turns on session compression (yes/no)

For the complete list of every possible field, run man ssh_config in your terminal—it's the definitive reference for all available options.

2. Can I set a default landing directory (like user@my.server.com:/default/landing/path)?

There's no dedicated "default directory" field, but you can replicate this behavior perfectly using RemoteCommand and RequestTTY in your config entry. Here's a working example:

Host my-server
    HostName my.server.com
    User your-username
    Port 22
    RemoteCommand cd /default/landing/path && exec $SHELL -l
    RequestTTY force

The exec $SHELL -l part is crucial—it ensures you get a full interactive login shell after changing directories, so your shell profiles (.bashrc, .profile, etc.) still load as expected. Without it, you'd end up in the right directory but without a proper interactive shell.

3. Can I disable PubkeyAuthentication in the config file and use password auth instead (I know scp can do this)?

Absolutely! You can force password authentication for a specific host by adding these two lines to your config entry:

Host my-server
    HostName my.server.com
    User your-username
    Port 22
    PubkeyAuthentication no
    PasswordAuthentication yes

This tells SSH to skip public key auth entirely and go straight to prompting for your password. Just double-check that the remote server allows password authentication: on the server, look for PasswordAuthentication yes in /etc/ssh/sshd_config, and restart the sshd service (sudo systemctl restart ssh) if you needed to enable it.


内容的提问来源于stack exchange,提问作者marcman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:05:39