0

I have an external VPS that has a VPN connection to another server using tinc on the ip address 10.0.0.2.

I am wanting to connect to my other server via ssh and scp over one command when connecting over a specific user - foo.

I am able to do this over ssh by adding this to my VPS /etc/ssh/sshd_config:

Match User foo
    ForceCommand ssh -t root@10.0.0.2 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no

Unfortunately when attempting scp (scp ~/Desktop/hello.txt foo@vps_ip:/) with this config I get:

Pseudo-terminal will not be allocated because stdin is not a terminal.
Warning: Permanently added '10.0.0.2' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-70-generic x86_64)
mesg: ttyname failed: Inappropriate ioctl for device

Also the same

0

Your ForceCommand needs to run a script that dynamically determines the correct ssh command.

  • Add "$SSH_ORIGINAL_COMMAND" as the remote command if the variable is non-empty locally. This allows things like ssh firsthost "uname -a" (for example) to correctly pass through to the second host.

  • Add -t only if stdin/stdout are a terminal. Batch transfers (scp, sftp, rsync, git) require a 8-bit-clean stream and forcing tty allocation would corrupt the data.

  • Consider not stacking SSH this way in the first place – better use either port-forwarding (iptables DNAT) or client-side JumpCommand.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.