Accessing a server via SSH (Secure Shell) is a common method for managing files on remote systems. In this case, the server in question runs Debian 12 and is behind a firewall that requires a proxy jump to be specified. Here's a step-by-step guide on how to set up SSH access with a proxy jump.
Prerequisites
- Install OpenSSH client on your local machine.
- Obtain the private key and username for the remote server.
Setting up SSH with Proxy Jump
-
Create a configuration file for the remote server.
$ touch ~/.ssh/config -
Open the configuration file in a text editor.
$ nano ~/.ssh/config -
Add the following content to the file, replacing
proxy_hostandproxy_userwith your proxy server's hostname and username, respectively.Host remote_server HostName proxy_host User proxy_user ForwardAgent yes ForwardX11 yes ForwardX11Trusted yes IdentityFile ~/.ssh/id_rsa ProxyCommand ssh -W %h:%p proxy_user@proxy_host -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -
Save and close the file.
-
Test the configuration.
$ ssh remote_serverIf everything is set up correctly, you should be able to log in to the remote server without being prompted for a password. The password prompt will appear only when you first log in to the proxy server.
Accessing the Server Files with SSHFS
-
Install SSHFS on your local machine.
$ sudo apt-get install sshfs -
Mount the remote server's directory.
$ sshfs remote_user@remote_server:/path/to/remote/directory /local/pathReplace
remote_userwith your username on the remote server,remote_server:/path/to/remote/directorywith the path to the directory you want to access, and/local/pathwith the local path where you want to mount the remote directory. -
Unmount the directory when you're done.
$ fusermount -u /local/path $ fusermount -u /local/path $ fusermount -d /local/path
Now you can access the server's files as if they were on your local machine.
References
- OpenSSH Manual Page: ssh(1)
- OpenSSH Manual Page: ssh_config(5)
- OpenSSH Manual Page: sshfs(1)
- SSHFS Manual Page: fusermount(8)
- Debian 12 Release Announcement: https://www.debian.org/News/2021/20210604
- SSHFS GitHub Repository: https://github.com/libfuse/sshfs
- SSHFS Manual: https://man.openbsd.org/sshfs.1
- SSH Proxy Command: https://www.ssh.com/ssh/proxycommand/
- Debian SSH Server Configuration: https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-debian-10-server
- SSHFS Troubleshooting: https://github.com/libfuse/sshfs/blob/master/doc/troubleshooting.md