0

I have Ubuntu 22.04 installed on a remote server. I can ssh to the server without any issues.

I often need to open a vnc tunnel with the following command:

ssh -L 5901:127.0.0.1:5901 -C -N -l username ip.add.re.ss

Sadly, including the option "-N", in other words "Do not execute a remote command" causes the connection to hang.

I am still requested to provide the passphrase for the RSA key, but once captured, nothing happens.

Removing -N works perfectly, but it does not serve the purpose in terms of security.

Happy to hear some ideas, as this is rather perplexing.

Here is the verbose output.

OpenSSH_8.6p1, LibreSSL 3.3.6
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to my.ip.add.res [my.ip.add.res] port 22.
debug1: Connection established.
debug1: identity file /Users/user/.ssh/id_rsa type 0
debug1: identity file /Users/user/.ssh/id_rsa-cert type -1
debug1: identity file /Users/user/.ssh/id_dsa type -1
debug1: identity file /Users/user/.ssh/id_dsa-cert type -1
debug1: identity file /Users/user/.ssh/id_ecdsa type -1
debug1: identity file /Users/user/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/user/.ssh/id_ecdsa_sk type -1
debug1: identity file /Users/user/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /Users/user/.ssh/id_ed25519 type -1
debug1: identity file /Users/user/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/user/.ssh/id_ed25519_sk type -1
debug1: identity file /Users/user/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /Users/user/.ssh/id_xmss type -1
debug1: identity file /Users/user/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.6
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.9p1 Ubuntu-3
debug1: compat_banner: match: OpenSSH_8.9p1 Ubuntu-3 pat OpenSSH* compat 0x04000000
debug1: Authenticating to my.ip.add.res:22 as 'user'
debug1: load_hostkeys: fopen /Users/user/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: [email protected]
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: [email protected]
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:XrQBKNemfjR4C9Yfuzc12jWk0n8yQPxUNdyhsmRRBSg
debug1: load_hostkeys: fopen /Users/user/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host 'my.ip.add.res' is known and matches the ED25519 host key.
debug1: Found key in /Users/user/.ssh/known_hosts:16
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /Users/user/.ssh/id_rsa RSA SHA256:FC8EntXzlysgFHBl8JkM1WAG+8MmaQbrkW64oA8D1Lc
debug1: Will attempt key: /Users/user/.ssh/id_dsa 
debug1: Will attempt key: /Users/user/.ssh/id_ecdsa 
debug1: Will attempt key: /Users/user/.ssh/id_ecdsa_sk 
debug1: Will attempt key: /Users/user/.ssh/id_ed25519 
debug1: Will attempt key: /Users/user/.ssh/id_ed25519_sk 
debug1: Will attempt key: /Users/user/.ssh/id_xmss 
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected]>
debug1: kex_input_ext_info: [email protected] (unrecognised)
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/user/.ssh/id_rsa RSA SHA256:FC8EntXzlysgFHBl8JkM1WAG+8MmaQbrkW64oA8D1Lc
debug1: Server accepts key: /Users/user/.ssh/id_rsa RSA SHA256:FC8EntXzlysgFHBl8JkM1WAG+8MmaQbrkW64oA8D1Lc
Enter passphrase for key '/Users/user/.ssh/id_rsa': 
debug1: Enabling compression at level 6.
debug1: Authentication succeeded (publickey).
Authenticated to my.ip.add.res ([my.ip.add.res]:22).
debug1: Local connections to LOCALHOST:5901 forwarded to remote address 127.0.0.1:5901
debug1: Local forwarding listening on ::1 port 5901.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 5901.
debug1: channel 1: new [port listener]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: filesystem full
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug1: client_input_hostkeys: searching /Users/user/.ssh/known_hosts for my.ip.add.res / (none)
debug1: client_input_hostkeys: searching /Users/user/.ssh/known_hosts2 for my.ip.add.res / (none)
debug1: client_input_hostkeys: hostkeys file /Users/user/.ssh/known_hosts2 does not exist
debug1: client_input_hostkeys: no new or deprecated keys from server
debug1: Remote: /home/user/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Remote: /home/user/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
4
  • Looks like this is the expected behaviour. You can not execute a command, but the ssh session is established and port forwarding works. ssh -L a.b.c.d:8081:e.f.g.h:22 -C -N e.f.g.h and nc a.b.c.d 8081 -v Output: Connection to a.b.c.d 8081 port [tcp/tproxy] succeeded! SSH-2.0-OpenSSH_8.9p1 Ubuntu-3
    – dummyuser
    Commented Oct 16, 2022 at 6:42
  • Sadly, this is not what happens. There is no "success" message, just a cursor: user@MacBook-Pro ~ % ssh -L 5901:127.0.0.1:5901 -C -N -l username my.ip.add.res Enter passphrase for key '/Users/user/.ssh/id_rsa': _ Commented Oct 16, 2022 at 8:51
  • 1
    Please, edit your question and add the output of your command with the -v option appended.
    – FedKad
    Commented Oct 16, 2022 at 8:58
  • @FedKad, I have just added the output with -v Commented Oct 16, 2022 at 11:22

1 Answer 1

0

Try the -T flag to request a terminal. Or if you're ok with creating an ssh config for this connection you can try using the RequestTTY yes flag. https://www.computerhope.com/jargon/r/requesttty.htm

1
  • Adding -T flag did not change the output. I will have a look at the RequestTTY option, thank you! Commented Oct 16, 2022 at 12:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .