Lines Matching defs:ssh
12 * called by a name other than "ssh" or "Secure Shell".
85 #include "ssh.h"
159 static void client_init_dispatch(struct ssh *ssh);
176 /* XXX move to struct ssh? */
236 set_control_persist_exit_time(struct ssh *ssh)
242 } else if (channel_still_open(ssh)) {
280 client_x11_get_proto(struct ssh *ssh, const char *display,
329 * ssh's willingness to forward X11 connections to
375 channel_set_x11_refuse_time(ssh,
451 client_check_window_change(struct ssh *ssh)
457 channel_send_window_changes(ssh);
461 client_global_request_reply(int type, u_int32_t seq, struct ssh *ssh)
468 gc->cb(ssh, type, seq, gc->ctx);
474 ssh_packet_set_alive_timeouts(ssh, 0);
486 server_alive_check(struct ssh *ssh)
490 if (ssh_packet_inc_alive_timeouts(ssh) > options.server_alive_count_max) {
494 if ((r = sshpkt_start(ssh, SSH2_MSG_GLOBAL_REQUEST)) != 0 ||
495 (r = sshpkt_put_cstring(ssh, "keepalive@openssh.com")) != 0 ||
496 (r = sshpkt_put_u8(ssh, 1)) != 0 || /* boolean: want reply */
497 (r = sshpkt_send(ssh)) != 0)
506 send_chaff(struct ssh *ssh)
510 if (ssh->kex == NULL || (ssh->kex->flags & KEX_HAS_PING) == 0)
518 if ((r = sshpkt_start(ssh, SSH2_MSG_PING)) != 0 ||
519 (r = sshpkt_put_cstring(ssh, "PING!")) != 0 ||
520 (r = sshpkt_send(ssh)) != 0)
567 obfuscate_keystroke_timing(struct ssh *ssh, struct timespec *timeout,
583 if (!channel_tty_open(ssh) || quit_pending) {
586 } else if (ssh_packet_is_rekeying(ssh)) {
589 } else if (!ssh_packet_interactive_data_to_write(ssh) &&
590 ssh_packet_have_data_to_write(ssh)) {
594 ssh_packet_have_data_to_write(ssh)) {
602 !ssh_packet_have_data_to_write(ssh)) {
604 if (send_chaff(ssh))
624 if (!active && ssh_packet_interactive_data_to_write(ssh) &&
625 channel_did_enqueue && ssh_packet_have_data_to_write(ssh)) {
656 return x11_channel_used_recently(ssh);
675 client_wait_until_can_do_something(struct ssh *ssh, struct pollfd **pfdp,
687 channel_prepare_poll(ssh, pfdp, npfd_allocp, npfd_activep, 2, &timeout);
692 if (session_closed && !channel_still_open(ssh) &&
693 !ssh_packet_have_data_to_write(ssh)) {
700 oready = obfuscate_keystroke_timing(ssh, &timeout, channel_did_enqueue);
706 (*pfdp)[1].events = (oready && ssh_packet_have_data_to_write(ssh)) ?
714 set_control_persist_exit_time(ssh);
719 if (options.rekey_interval > 0 && !ssh_packet_is_rekeying(ssh)) {
721 ssh_packet_get_rekey_timeout(ssh));
751 server_alive_check(ssh);
782 client_process_net_input(struct ssh *ssh)
791 if ((r = ssh_packet_process_read(ssh, connection_in)) == 0)
806 client_status_confirm(struct ssh *ssh, int type, Channel *c, void *ctx)
860 mux_tty_alloc_failed(ssh, c);
862 chan_read_failed(ssh, c);
863 chan_write_failed(ssh, c);
870 client_abandon_status_confirm(struct ssh *ssh, Channel *c, void *ctx)
876 client_expect_confirm(struct ssh *ssh, int id, const char *request,
884 channel_register_status_confirm(ssh, id, client_status_confirm,
969 * - ssh -N (no session)
976 process_cmdline(struct ssh *ssh)
1050 ok = channel_request_rforward_cancel(ssh, &fwd) == 0;
1052 ok = channel_cancel_lport_listener(ssh, &fwd,
1055 ok = channel_cancel_lport_listener(ssh, &fwd,
1076 if (!channel_setup_local_fwd_listener(ssh, &fwd,
1082 if (channel_request_remote_forwarding(ssh, &fwd) < 0) {
1119 {"^Z", "suspend ssh", SUPPRESS_MUXCLIENT},
1121 {"&", "background ssh (when waiting for connections to terminate)",
1162 process_escapes(struct ssh *ssh, Channel *c,
1195 channel_force_close(ssh, c, 1);
1219 "%c^Z [suspend ssh]\r\n",
1233 channel_request_start(ssh, c->self, "break", 0);
1234 if ((r = sshpkt_put_u32(ssh, 1000)) != 0 ||
1235 (r = sshpkt_send(ssh)) != 0)
1240 if (ssh->compat & SSH_BUG_NOREKEY)
1285 channel_stop_listening(ssh);
1316 s = channel_open_message(ssh);
1331 process_cmdline(ssh);
1384 client_process_buffered_input_packets(struct ssh *ssh)
1386 ssh_dispatch_run_fatal(ssh, DISPATCH_NONBLOCK, &quit_pending);
1405 client_filter_cleanup(struct ssh *ssh, int cid, void *ctx)
1411 client_simple_escape_filter(struct ssh *ssh, Channel *c, char *buf, int len)
1416 return process_escapes(ssh, c, c->input, c->output, c->extended,
1421 client_channel_closed(struct ssh *ssh, int id, int force, void *arg)
1423 channel_cancel_cleanup(ssh, id);
1435 client_loop(struct ssh *ssh, int have_pty, int escape_char_arg,
1488 connection_in = ssh_packet_get_connection_in(ssh);
1489 connection_out = ssh_packet_get_connection_out(ssh);
1493 client_init_dispatch(ssh);
1514 channel_register_filter(ssh, session_ident,
1520 channel_register_cleanup(ssh, session_ident,
1538 client_process_buffered_input_packets(ssh);
1540 if (session_closed && !channel_still_open(ssh))
1543 if (ssh_packet_is_rekeying(ssh)) {
1548 if ((r = kex_start_rekex(ssh)) != 0)
1556 if (ssh_packet_not_very_much_data_to_write(ssh))
1557 channel_did_enqueue = channel_output_poll(ssh);
1563 client_check_window_change(ssh);
1573 client_wait_until_can_do_something(ssh, &pfd, &npfd_alloc,
1583 channel_after_poll(ssh, pfd, npfd_active);
1587 client_process_net_input(ssh);
1593 if ((r = ssh_packet_check_rekey(ssh)) != 0)
1601 if ((r = ssh_packet_write_poll(ssh)) != 0) {
1602 sshpkt_fatal(ssh, r,
1634 if ((r = sshpkt_start(ssh, SSH2_MSG_DISCONNECT)) != 0 ||
1635 (r = sshpkt_put_u32(ssh, SSH2_DISCONNECT_BY_APPLICATION)) != 0 ||
1636 (r = sshpkt_put_cstring(ssh, "disconnected by user")) != 0 ||
1637 (r = sshpkt_put_cstring(ssh, "")) != 0 || /* language tag */
1638 (r = sshpkt_send(ssh)) != 0 ||
1639 (r = ssh_packet_write_wait(ssh)) != 0)
1642 channel_free_all(ssh);
1665 ssh_packet_get_bytes(ssh, &ibytes, &obytes);
1679 client_request_forwarded_tcpip(struct ssh *ssh, const char *request_type,
1689 if ((r = sshpkt_get_cstring(ssh, &listen_address, NULL)) != 0 ||
1690 (r = sshpkt_get_u32(ssh, &listen_port)) != 0 ||
1691 (r = sshpkt_get_cstring(ssh, &originator_address, NULL)) != 0 ||
1692 (r = sshpkt_get_u32(ssh, &originator_port)) != 0 ||
1693 (r = sshpkt_get_end(ssh)) != 0)
1704 c = channel_connect_by_listen_address(ssh,
1739 client_request_forwarded_streamlocal(struct ssh *ssh,
1747 if ((r = sshpkt_get_cstring(ssh, &listen_path, NULL)) != 0 ||
1748 (r = sshpkt_get_string(ssh, NULL, NULL)) != 0 || /* reserved */
1749 (r = sshpkt_get_end(ssh)) != 0)
1754 c = channel_connect_by_listen_path(ssh, listen_path,
1761 client_request_x11(struct ssh *ssh, const char *request_type, int rchan)
1769 error("Warning: ssh server tried X11 forwarding.");
1779 if ((r = sshpkt_get_cstring(ssh, &originator, NULL)) != 0 ||
1780 (r = sshpkt_get_u32(ssh, &originator_port)) != 0 ||
1781 (r = sshpkt_get_end(ssh)) != 0)
1788 sock = x11_connect_display(ssh);
1791 c = channel_new(ssh, "x11-connection",
1799 client_request_agent(struct ssh *ssh, const char *request_type, int rchan)
1805 error("Warning: ssh server tried agent forwarding.");
1820 if ((r = ssh_agent_bind_hostkey(sock, ssh->kex->initial_hostkey,
1821 ssh->kex->session_id, ssh->kex->initial_sig, 1)) == 0)
1826 c = channel_new(ssh, "agent-connection",
1835 client_request_tun_fwd(struct ssh *ssh, int tun_mode,
1854 c = channel_new(ssh, "tun-connection", SSH_CHANNEL_OPENING, fd, fd, -1,
1859 channel_register_open_confirm(ssh, c->self, cb, cbctx);
1861 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_OPEN)) != 0 ||
1862 (r = sshpkt_put_cstring(ssh, "tun@openssh.com")) != 0 ||
1863 (r = sshpkt_put_u32(ssh, c->self)) != 0 ||
1864 (r = sshpkt_put_u32(ssh, c->local_window_max)) != 0 ||
1865 (r = sshpkt_put_u32(ssh, c->local_maxpacket)) != 0 ||
1866 (r = sshpkt_put_u32(ssh, tun_mode)) != 0 ||
1867 (r = sshpkt_put_u32(ssh, remote_tun)) != 0 ||
1868 (r = sshpkt_send(ssh)) != 0)
1869 sshpkt_fatal(ssh, r, "%s: send reply", __func__);
1876 client_input_channel_open(int type, u_int32_t seq, struct ssh *ssh)
1885 if ((r = sshpkt_get_cstring(ssh, &ctype, &len)) != 0 ||
1886 (r = sshpkt_get_u32(ssh, &rchan)) != 0 ||
1887 (r = sshpkt_get_u32(ssh, &rwindow)) != 0 ||
1888 (r = sshpkt_get_u32(ssh, &rmaxpack)) != 0)
1895 c = client_request_forwarded_tcpip(ssh, ctype, rchan, rwindow,
1898 c = client_request_forwarded_streamlocal(ssh, ctype, rchan);
1900 c = client_request_x11(ssh, ctype, rchan);
1902 c = client_request_agent(ssh, ctype, rchan);
1913 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_OPEN_CONFIRMATION)) != 0 ||
1914 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 ||
1915 (r = sshpkt_put_u32(ssh, c->self)) != 0 ||
1916 (r = sshpkt_put_u32(ssh, c->local_window)) != 0 ||
1917 (r = sshpkt_put_u32(ssh, c->local_maxpacket)) != 0 ||
1918 (r = sshpkt_send(ssh)) != 0)
1919 sshpkt_fatal(ssh, r, "%s: send reply", __func__);
1923 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_OPEN_FAILURE)) != 0 ||
1924 (r = sshpkt_put_u32(ssh, rchan)) != 0 ||
1925 (r = sshpkt_put_u32(ssh, SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED)) != 0 ||
1926 (r = sshpkt_put_cstring(ssh, "open failed")) != 0 ||
1927 (r = sshpkt_put_cstring(ssh, "")) != 0 ||
1928 (r = sshpkt_send(ssh)) != 0)
1929 sshpkt_fatal(ssh, r, "%s: send failure", __func__);
1938 client_input_channel_req(int type, u_int32_t seq, struct ssh *ssh)
1946 if ((r = sshpkt_get_u32(ssh, &id)) != 0)
1949 c = channel_lookup(ssh, id);
1950 if (channel_proxy_upstream(c, type, seq, ssh))
1952 if ((r = sshpkt_get_cstring(ssh, &rtype, NULL)) != 0 ||
1953 (r = sshpkt_get_u8(ssh, &reply)) != 0)
1963 if ((r = sshpkt_get_end(ssh)) != 0)
1965 chan_rcvd_eow(ssh, c);
1967 if ((r = sshpkt_get_u32(ssh, &exitval)) != 0)
1970 mux_exit_message(ssh, c, exitval);
1981 if ((r = sshpkt_get_end(ssh)) != 0)
1987 if ((r = sshpkt_start(ssh, success ?
1989 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 ||
1990 (r = sshpkt_send(ssh)) != 0)
1991 sshpkt_fatal(ssh, r, "%s: send failure", __func__);
2123 * that contain more than two entries (ssh never writes these).
2315 client_global_hostkeys_prove_confirm(struct ssh *ssh, int type,
2336 ssh->kex->hostkey_alg)) == KEY_RSA)
2337 rsa_kexalg = ssh->kex->hostkey_alg;
2354 ssh->kex->session_id)) != 0 ||
2358 if ((r = sshpkt_get_string_direct(ssh, &sig, &siglen)) != 0) {
2400 if ((r = sshpkt_get_end(ssh)) != 0) {
2419 client_input_hostkeys(struct ssh *ssh)
2427 static int hostkeys_seen = 0; /* XXX use struct ssh */
2428 extern struct sockaddr_storage hostaddr; /* XXX from ssh.c */
2439 while (ssh_packet_remaining(ssh) > 0) {
2442 if ((r = sshpkt_get_string_direct(ssh, &blob, &len)) != 0) {
2585 if ((r = sshpkt_start(ssh, SSH2_MSG_GLOBAL_REQUEST)) != 0 ||
2586 (r = sshpkt_put_cstring(ssh,
2588 (r = sshpkt_put_u8(ssh, 1)) != 0) /* bool: want reply */
2597 (r = sshpkt_put_stringb(ssh, buf)) != 0)
2600 if ((r = sshpkt_send(ssh)) != 0)
2625 client_input_global_request(int type, u_int32_t seq, struct ssh *ssh)
2631 if ((r = sshpkt_get_cstring(ssh, &rtype, NULL)) != 0 ||
2632 (r = sshpkt_get_u8(ssh, &want_reply)) != 0)
2637 success = client_input_hostkeys(ssh);
2639 if ((r = sshpkt_start(ssh, success ? SSH2_MSG_REQUEST_SUCCESS :
2641 (r = sshpkt_send(ssh)) != 0 ||
2642 (r = ssh_packet_write_wait(ssh)) != 0)
2652 client_send_env(struct ssh *ssh, int id, const char *name, const char *val)
2657 channel_request_start(ssh, id, "env", 0);
2658 if ((r = sshpkt_put_cstring(ssh, name)) != 0 ||
2659 (r = sshpkt_put_cstring(ssh, val)) != 0 ||
2660 (r = sshpkt_send(ssh)) != 0)
2665 client_session2_setup(struct ssh *ssh, int id, int want_tty, int want_subsystem,
2676 if ((c = channel_lookup(ssh, id)) == NULL)
2679 ssh_packet_set_interactive(ssh, want_tty,
2689 channel_request_start(ssh, id, "pty-req", 1);
2690 client_expect_confirm(ssh, id, "PTY allocation", CONFIRM_TTY);
2691 if ((r = sshpkt_put_cstring(ssh, term != NULL ? term : ""))
2693 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_col)) != 0 ||
2694 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_row)) != 0 ||
2695 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_xpixel)) != 0 ||
2696 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_ypixel)) != 0)
2700 ssh_tty_make_modes(ssh, -1, tiop);
2701 if ((r = sshpkt_send(ssh)) != 0)
2731 client_send_env(ssh, id, name, val);
2743 client_send_env(ssh, id, name, val);
2754 channel_request_start(ssh, id, "subsystem", 1);
2755 client_expect_confirm(ssh, id, "subsystem",
2760 channel_request_start(ssh, id, "exec", 1);
2761 client_expect_confirm(ssh, id, "exec", CONFIRM_CLOSE);
2763 if ((r = sshpkt_put_stringb(ssh, cmd)) != 0 ||
2764 (r = sshpkt_send(ssh)) != 0)
2767 channel_request_start(ssh, id, "shell", 1);
2768 client_expect_confirm(ssh, id, "shell", CONFIRM_CLOSE);
2769 if ((r = sshpkt_send(ssh)) != 0)
2778 client_init_dispatch(struct ssh *ssh)
2780 ssh_dispatch_init(ssh, &dispatch_protocol_error);
2782 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_CLOSE, &channel_input_oclose);
2783 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_DATA, &channel_input_data);
2784 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_EOF, &channel_input_ieof);
2785 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_EXTENDED_DATA, &channel_input_extended_data);
2786 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_OPEN, &client_input_channel_open);
2787 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_OPEN_CONFIRMATION, &channel_input_open_confirmation);
2788 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_OPEN_FAILURE, &channel_input_open_failure);
2789 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_REQUEST, &client_input_channel_req);
2790 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust);
2791 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_SUCCESS, &channel_input_status_confirm);
2792 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_FAILURE, &channel_input_status_confirm);
2793 ssh_dispatch_set(ssh, SSH2_MSG_GLOBAL_REQUEST, &client_input_global_request);
2796 ssh_dispatch_set(ssh, SSH2_MSG_KEXINIT, &kex_input_kexinit);
2799 ssh_dispatch_set(ssh, SSH2_MSG_REQUEST_FAILURE, &client_global_request_reply);
2800 ssh_dispatch_set(ssh, SSH2_MSG_REQUEST_SUCCESS, &client_global_request_reply);