[{"data":1,"prerenderedAt":1087},["ShallowReactive",2],{"article-20210803-ssh-allowed-commands":3},{"article":4,"surround":1078},{"id":5,"title":6,"authorKey":7,"body":8,"codeLinks":1051,"createdAt":1052,"description":1053,"excerpt":1054,"extension":1066,"image":1067,"meta":1068,"navigation":484,"path":1069,"published":1070,"readingTime":504,"revisedAt":1051,"seo":1071,"stem":1072,"tags":1073,"__hash__":1077},"articles\u002Farticles\u002F20210803-ssh-allowed-commands.md","Restrict commands by SSH authorized_keys command option","philip",{"type":9,"value":10,"toc":1047},"minimark",[11,24,29,47,56,89,92,105,108,124,127,132,147,150,203,212,220,229,256,270,289,299,330,355,358,362,374,391,396,415,427,449,459,469,916,923,941,948,1024,1031,1037,1043],[12,13,14,15,19,20,23],"p",{},"SSH ",[16,17,18],"code",{},"authorized_keys"," allows you to define a command which is executed upon authentication with a specific key by prefixing it with the ",[16,21,22],{},"command=\"cmd\""," option.",[12,25,26,28],{},[16,27,18],{}," man page explains this wonderful feature as follows:",[30,31,32,40],"blockquote",{},[12,33,34],{},[35,36,37],"strong",{},[16,38,39],{},"command=\"command\"",[12,41,42,43,46],{},"Specifies that the command is executed whenever this key is used for authentication.  The command supplied by the user (if any) is ignored.\n(...)\nThis option might be useful to restrict certain public keys to perform just a specific operation.  An example might be a key that permits remote backups but nothing else.\n(...)\nThe command originally supplied by the client is available in the ",[16,44,45],{},"SSH_ORIGINAL_COMMAND"," environment variable.",[12,48,49,50,52,53,55],{},"The syntax goes like this, put ",[16,51,22],{}," and all other options before a pubkey in ",[16,54,18],{},":",[57,58,63],"pre",{"className":59,"code":60,"language":61,"meta":62,"style":62},"language-bash shiki shiki-themes github-light-default github-light-default github-dark-default","command=\"cmd\",no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-X11-forwarding ssh-rsa AAAAB3N...\n","bash","",[16,64,65],{"__ignoreMap":62},[66,67,70,74,78,82,86],"span",{"class":68,"line":69},"line",1,[66,71,73],{"class":72},"s_bOF","command",[66,75,77],{"class":76},"s5nWI","=",[66,79,81],{"class":80},"s-BGO","\"cmd\",no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-X11-forwarding",[66,83,85],{"class":84},"sQJ0q"," ssh-rsa",[66,87,88],{"class":80}," AAAAB3N...\n",[12,90,91],{},"A detailed description of these options can be found here:",[93,94,95],"ul",{},[96,97,98],"li",{},[99,100,104],"a",{"href":101,"rel":102},"https:\u002F\u002Fwww.ssh.com\u002Facademy\u002Fssh\u002Fauthorized_keys\u002Fopenssh",[103],"nofollow","Configuring authorized_keys for OpenSSH",[12,106,107],{},"You might have missed the two use cases from my other blog posts, as they are quite long and complex:",[93,109,110,117],{},[96,111,112,116],{},[99,113,115],{"href":114},"\u002Farticles\u002F20180306-simple-and-secure-external-backup","2018-03-06 Simple and Secure External Backup",": Restricting SSH access to rsync only from a specific directory",[96,118,119,123],{},[99,120,122],{"href":121},"\u002Farticles\u002F20210803-secure-zfs-encrypted-extbackup","2021-08-03 Secure External Backup with ZFS Native Encryption",": Restricting SSH access to a list of specific command patterns",[12,125,126],{},"So here's the two use cases in short:",[128,129,131],"h2",{"id":130},"use-case-1-limit-rsync-to-a-directory-rrsync","Use Case 1: Limit rsync to a directory (rrsync)",[12,133,134,135,138,139,142,143,146],{},"Let's suppose we need full root permissions to pull data from a backup server, but its access should be limited to ",[16,136,137],{},"rsync"," from a specific directory and not executing any other commands on the remote ",[16,140,141],{},"backup"," server. The host that pulls data is going to be called ",[16,144,145],{},"extbackup",".",[12,148,149],{},"There is a simple rsync wrapper for this which comes shipped with Debian's rsync package but first needs to be unpacked\u002Finstalled:",[57,151,153],{"className":59,"code":152,"language":61,"meta":62,"style":62},"backup$ zcat \u002Fusr\u002Fshare\u002Fdoc\u002Frsync\u002Fscripts\u002Frrsync.gz > \u002Fusr\u002Flocal\u002Fbin\u002Frrsync\nbackup$ chmod 0755 \u002Fusr\u002Flocal\u002Fbin\u002Frrsync\nbackup$ ln -s \u002Fusr\u002Flocal\u002Fbin\u002Frrsync \u002Fusr\u002Fbin\u002Frrsync\n",[16,154,155,172,186],{"__ignoreMap":62},[66,156,157,160,163,166,169],{"class":68,"line":69},[66,158,159],{"class":84},"backup$",[66,161,162],{"class":80}," zcat",[66,164,165],{"class":80}," \u002Fusr\u002Fshare\u002Fdoc\u002Frsync\u002Fscripts\u002Frrsync.gz",[66,167,168],{"class":76}," >",[66,170,171],{"class":80}," \u002Fusr\u002Flocal\u002Fbin\u002Frrsync\n",[66,173,175,177,180,184],{"class":68,"line":174},2,[66,176,159],{"class":84},[66,178,179],{"class":80}," chmod",[66,181,183],{"class":182},"sDkKp"," 0755",[66,185,171],{"class":80},[66,187,189,191,194,197,200],{"class":68,"line":188},3,[66,190,159],{"class":84},[66,192,193],{"class":80}," ln",[66,195,196],{"class":182}," -s",[66,198,199],{"class":80}," \u002Fusr\u002Flocal\u002Fbin\u002Frrsync",[66,201,202],{"class":80}," \u002Fusr\u002Fbin\u002Frrsync\n",[12,204,205,206,209,210,55],{},"We then add this to ",[16,207,208],{},"\u002Fetc\u002Fsudoers.d\u002Fextbackup"," on ",[16,211,141],{},[57,213,218],{"className":214,"code":216,"language":217},[215],"language-text","%backuppers ALL= NOPASSWD:SETENV: \u002Fusr\u002Fbin\u002Frrsync\n","text",[16,219,216],{"__ignoreMap":62},[12,221,222,223,225,226,55],{},"Let's now create a specific user ",[16,224,145],{}," and add him to group ",[16,227,228],{},"backuppers",[57,230,232],{"className":59,"code":231,"language":61,"meta":62,"style":62},"backup$ adduser extbackup\nbackup$ adduser extbackup backuppers\n",[16,233,234,244],{"__ignoreMap":62},[66,235,236,238,241],{"class":68,"line":69},[66,237,159],{"class":84},[66,239,240],{"class":80}," adduser",[66,242,243],{"class":80}," extbackup\n",[66,245,246,248,250,253],{"class":68,"line":174},[66,247,159],{"class":84},[66,249,240],{"class":80},[66,251,252],{"class":80}," extbackup",[66,254,255],{"class":80}," backuppers\n",[12,257,258,259,261,262,265,266,269],{},"Add the public key of ",[16,260,145],{}," (found in ",[16,263,264],{},"extbackup:~\u002F.ssh\u002Fid_rsa.pub",") to ",[16,267,268],{},"backup:\u002Fhome\u002Fextbackup\u002F.ssh\u002Fauthorized_keys",", prefixed by the following options:",[57,271,273],{"className":59,"code":272,"language":61,"meta":62,"style":62},"command=\"sudo -E \u002Fusr\u002Fbin\u002Frrsync -ro \u002Fbackups\u002F\",no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-X11-forwarding ssh-rsa AAAABxyz...\n",[16,274,275],{"__ignoreMap":62},[66,276,277,279,281,284,286],{"class":68,"line":69},[66,278,73],{"class":72},[66,280,77],{"class":76},[66,282,283],{"class":80},"\"sudo -E \u002Fusr\u002Fbin\u002Frrsync -ro \u002Fbackups\u002F\",no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-X11-forwarding",[66,285,85],{"class":84},[66,287,288],{"class":80}," AAAABxyz...\n",[12,290,291,292,294,295,298],{},"This limits ",[16,293,145],{}," to only pull data from ",[16,296,297],{},"backup:\u002Fbackups\u002F"," directory over rsync. Test-run:",[57,300,302],{"className":59,"code":301,"language":61,"meta":62,"style":62},"extbackup$ rsync -aH --numeric-ids --delete --delete-before extbackup@backup: \u002Fmnt\u002Fbackups\n",[16,303,304],{"__ignoreMap":62},[66,305,306,309,312,315,318,321,324,327],{"class":68,"line":69},[66,307,308],{"class":84},"extbackup$",[66,310,311],{"class":80}," rsync",[66,313,314],{"class":182}," -aH",[66,316,317],{"class":182}," --numeric-ids",[66,319,320],{"class":182}," --delete",[66,322,323],{"class":182}," --delete-before",[66,325,326],{"class":80}," extbackup@backup:",[66,328,329],{"class":80}," \u002Fmnt\u002Fbackups\n",[30,331,332],{},[12,333,334,335,337,338,340,341,344,345,347,348,351,352,354],{},"Explanation: ",[16,336,145],{},"'s root user rsyncs data from ",[16,339,297],{}," to ",[16,342,343],{},"\u002Fmnt\u002Fbackups"," but only needs to provide the relative path to ",[16,346,141],{}," as rsyncing is enforced over rrsync to ",[16,349,350],{},"\u002Fbackups\u002F"," directory on the remote side. If we want to pull all data from ",[16,353,297],{},", simply provide an empty relative path after the colon.",[12,356,357],{},"Isn't that cool? We can pull data with root rights from our backup server but are limited to one specific directory and are not able to execute any other commands except rsync!",[128,359,361],{"id":360},"use-case-2-restrict-to-specific-command-patterns","Use Case 2: Restrict to specific command patterns",[12,363,364,365,370,371,373],{},"As pointed out ",[99,366,369],{"href":367,"rel":368},"https:\u002F\u002Fserverfault.com\u002Fa\u002F803873\u002F299863",[103],"here",", OpenSSH's ",[16,372,18],{}," command option enforces a single command (by overriding the original command). So the question was:",[30,375,376],{},[12,377,378,379,381,382,385,386,390],{},"The ",[16,380,18],{}," has a ",[16,383,384],{},"command=\"...\""," option that restricts a key to a single command. Is there a way to restrict a key to ",[387,388,389],"em",{},"multiple"," commands? E.g. by having a regex there, or by editing some other configuration file?",[12,392,393,394,46],{},"This can be simply accomplished by a wrapper script, as OpenSSH makes the original command supplied by the client available in the ",[16,395,45],{},[12,397,398,399,402,403,405,406,408,409,414],{},"In ",[99,400,401],{"href":121},"Secure External Backup with ZFS Native Encryption"," our requirement was to limit root access over SSH to only specific command patterns, so that the client (in this case ",[16,404,145],{}," which pulls data from ",[16,407,141],{}," server) was only able to execute commands which were needed for ",[99,410,413],{"href":411,"rel":412},"https:\u002F\u002Fpve.proxmox.com\u002Fwiki\u002FPVE-zsync",[103],"PVE-zsync"," backup\u002Freplication.",[12,416,417,418,420,421,423,424,55],{},"To accomplish this specific restrictions, we need to use a script in ",[16,419,73],{}," section before the ",[16,422,145],{},"'s pubkey in ",[16,425,426],{},".ssh\u002Fauthorized_keys",[57,428,430],{"className":59,"code":429,"language":61,"meta":62,"style":62},"command=\"\u002Froot\u002F.ssh\u002Fallowed-commands.sh\",no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-X11-forwarding ssh-rsa AAAAB3N... root@extbackup\n",[16,431,432],{"__ignoreMap":62},[66,433,434,436,438,441,443,446],{"class":68,"line":69},[66,435,73],{"class":72},[66,437,77],{"class":76},[66,439,440],{"class":80},"\"\u002Froot\u002F.ssh\u002Fallowed-commands.sh\",no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-X11-forwarding",[66,442,85],{"class":84},[66,444,445],{"class":80}," AAAAB3N...",[66,447,448],{"class":80}," root@extbackup\n",[12,450,451,454,455,458],{},[16,452,453],{},"allowed-commands.sh"," then does pattern matching to verify the commands - using ",[16,456,457],{},"$SSH_ORIGINAL_COMMAND"," to get the original command:",[30,460,461],{},[12,462,463,464,146],{},"For numeric ranges in Bash regexes I have used ",[99,465,468],{"href":466,"rel":467},"https:\u002F\u002F3widgets.com\u002F",[103],"Regex Numeric Range Generator",[57,470,472],{"className":59,"code":471,"filename":453,"language":61,"meta":62,"style":62},"#!\u002Fbin\u002Fbash\n\n## CONFIGURATION ##############################################\nveid_pattern='(19[4-9]|2[0-4][0-9]|25[0-4])'\nbackup_srcdir='\u002Fbackup'\npool_name=dpool\n###############################################################\n\n# Regex patterns\n# WARNING: '\\w' is not supported in Bash, so we need to use '[:alnum:]' instead\nds_pattern=\"${pool_name}\u002Fzfsdisks\u002Fsubvol-${veid_pattern}-disk-1\"\nts_pattern='20[2-9][0-9]-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])_(0[0-9]|1[0-9]|2[0-3])(:(0[0-9]|[1-5][0-9])){2}'\nsnap_prefix_pattern='rep_extbackup_([1-9]a_)?'\nsnap_pattern=\"@${snap_prefix_pattern}${ts_pattern}\"\nds_snap_pattern=\"${ds_pattern}${snap_pattern}\"\n\npatt1='zfs list -r( -)?t snapshot -Ho name( -S creation)? '\"$ds_pattern($snap_pattern)?\"\npatt2='zfs (snapshot|destroy) '\"$ds_snap_pattern\"\npatt3='zfs send '\"(-i $ds_snap_pattern )?-- $ds_snap_pattern\"\npatt4=\"zfs rename $ds_snap_pattern $ds_snap_pattern\" # only used in extbackup-migrate-zfs-snaps.sh\n\ncmd=\"$SSH_ORIGINAL_COMMAND\"\n\nif [[ \"$cmd\" == 'list-datasets' ]]; then\n    # special command to get a server list of all datasets and mountpoints\n    zfs list -H -o name,mountpoint,usedds | grep $backup_srcdir\n    exit\nelif [[ $cmd =~ ^$patt1$ || $cmd =~ ^$patt2$ || $cmd =~ ^$patt3$ || $cmd =~ ^$patt4$ ]]; then\n    $SSH_ORIGINAL_COMMAND\n    exit\nelse\n    logger \"$(basename $0) violation: $cmd\"\n    echo \"Access denied\"\n    exit 1\nfi\n",[16,473,474,480,486,491,502,513,524,530,535,541,547,568,579,590,611,629,634,657,674,694,716,721,735,740,768,774,801,807,853,859,864,870,892,901,910],{"__ignoreMap":62},[66,475,476],{"class":68,"line":69},[66,477,479],{"class":478},"s9BHP","#!\u002Fbin\u002Fbash\n",[66,481,482],{"class":68,"line":174},[66,483,485],{"emptyLinePlaceholder":484},true,"\n",[66,487,488],{"class":68,"line":188},[66,489,490],{"class":478},"## CONFIGURATION ##############################################\n",[66,492,494,497,499],{"class":68,"line":493},4,[66,495,496],{"class":72},"veid_pattern",[66,498,77],{"class":76},[66,500,501],{"class":80},"'(19[4-9]|2[0-4][0-9]|25[0-4])'\n",[66,503,505,508,510],{"class":68,"line":504},5,[66,506,507],{"class":72},"backup_srcdir",[66,509,77],{"class":76},[66,511,512],{"class":80},"'\u002Fbackup'\n",[66,514,516,519,521],{"class":68,"line":515},6,[66,517,518],{"class":72},"pool_name",[66,520,77],{"class":76},[66,522,523],{"class":80},"dpool\n",[66,525,527],{"class":68,"line":526},7,[66,528,529],{"class":478},"###############################################################\n",[66,531,533],{"class":68,"line":532},8,[66,534,485],{"emptyLinePlaceholder":484},[66,536,538],{"class":68,"line":537},9,[66,539,540],{"class":478},"# Regex patterns\n",[66,542,544],{"class":68,"line":543},10,[66,545,546],{"class":478},"# WARNING: '\\w' is not supported in Bash, so we need to use '[:alnum:]' instead\n",[66,548,550,553,555,558,560,563,565],{"class":68,"line":549},11,[66,551,552],{"class":72},"ds_pattern",[66,554,77],{"class":76},[66,556,557],{"class":80},"\"${",[66,559,518],{"class":72},[66,561,562],{"class":80},"}\u002Fzfsdisks\u002Fsubvol-${",[66,564,496],{"class":72},[66,566,567],{"class":80},"}-disk-1\"\n",[66,569,571,574,576],{"class":68,"line":570},12,[66,572,573],{"class":72},"ts_pattern",[66,575,77],{"class":76},[66,577,578],{"class":80},"'20[2-9][0-9]-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])_(0[0-9]|1[0-9]|2[0-3])(:(0[0-9]|[1-5][0-9])){2}'\n",[66,580,582,585,587],{"class":68,"line":581},13,[66,583,584],{"class":72},"snap_prefix_pattern",[66,586,77],{"class":76},[66,588,589],{"class":80},"'rep_extbackup_([1-9]a_)?'\n",[66,591,593,596,598,601,603,606,608],{"class":68,"line":592},14,[66,594,595],{"class":72},"snap_pattern",[66,597,77],{"class":76},[66,599,600],{"class":80},"\"@${",[66,602,584],{"class":72},[66,604,605],{"class":80},"}${",[66,607,573],{"class":72},[66,609,610],{"class":80},"}\"\n",[66,612,614,617,619,621,623,625,627],{"class":68,"line":613},15,[66,615,616],{"class":72},"ds_snap_pattern",[66,618,77],{"class":76},[66,620,557],{"class":80},[66,622,552],{"class":72},[66,624,605],{"class":80},[66,626,595],{"class":72},[66,628,610],{"class":80},[66,630,632],{"class":68,"line":631},16,[66,633,485],{"emptyLinePlaceholder":484},[66,635,637,640,642,645,648,651,654],{"class":68,"line":636},17,[66,638,639],{"class":72},"patt1",[66,641,77],{"class":76},[66,643,644],{"class":80},"'zfs list -r( -)?t snapshot -Ho name( -S creation)? '\"",[66,646,647],{"class":72},"$ds_pattern",[66,649,650],{"class":80},"(",[66,652,653],{"class":72},"$snap_pattern",[66,655,656],{"class":80},")?\"\n",[66,658,660,663,665,668,671],{"class":68,"line":659},18,[66,661,662],{"class":72},"patt2",[66,664,77],{"class":76},[66,666,667],{"class":80},"'zfs (snapshot|destroy) '\"",[66,669,670],{"class":72},"$ds_snap_pattern",[66,672,673],{"class":80},"\"\n",[66,675,677,680,682,685,687,690,692],{"class":68,"line":676},19,[66,678,679],{"class":72},"patt3",[66,681,77],{"class":76},[66,683,684],{"class":80},"'zfs send '\"(-i ",[66,686,670],{"class":72},[66,688,689],{"class":80}," )?-- ",[66,691,670],{"class":72},[66,693,673],{"class":80},[66,695,697,700,702,705,707,710,713],{"class":68,"line":696},20,[66,698,699],{"class":72},"patt4",[66,701,77],{"class":76},[66,703,704],{"class":80},"\"zfs rename ",[66,706,670],{"class":72},[66,708,709],{"class":72}," $ds_snap_pattern",[66,711,712],{"class":80},"\"",[66,714,715],{"class":478}," # only used in extbackup-migrate-zfs-snaps.sh\n",[66,717,719],{"class":68,"line":718},21,[66,720,485],{"emptyLinePlaceholder":484},[66,722,724,727,729,731,733],{"class":68,"line":723},22,[66,725,726],{"class":72},"cmd",[66,728,77],{"class":76},[66,730,712],{"class":80},[66,732,457],{"class":72},[66,734,673],{"class":80},[66,736,738],{"class":68,"line":737},23,[66,739,485],{"emptyLinePlaceholder":484},[66,741,743,746,749,751,754,756,759,762,765],{"class":68,"line":742},24,[66,744,745],{"class":76},"if",[66,747,748],{"class":72}," [[ ",[66,750,712],{"class":80},[66,752,753],{"class":72},"$cmd",[66,755,712],{"class":80},[66,757,758],{"class":76}," ==",[66,760,761],{"class":80}," 'list-datasets'",[66,763,764],{"class":72}," ]]; ",[66,766,767],{"class":76},"then\n",[66,769,771],{"class":68,"line":770},25,[66,772,773],{"class":478},"    # special command to get a server list of all datasets and mountpoints\n",[66,775,777,780,783,786,789,792,795,798],{"class":68,"line":776},26,[66,778,779],{"class":84},"    zfs",[66,781,782],{"class":80}," list",[66,784,785],{"class":182}," -H",[66,787,788],{"class":182}," -o",[66,790,791],{"class":80}," name,mountpoint,usedds",[66,793,794],{"class":76}," |",[66,796,797],{"class":84}," grep",[66,799,800],{"class":72}," $backup_srcdir\n",[66,802,804],{"class":68,"line":803},27,[66,805,806],{"class":182},"    exit\n",[66,808,810,813,816,819,822,825,828,830,833,835,837,839,842,844,846,848,851],{"class":68,"line":809},28,[66,811,812],{"class":76},"elif",[66,814,815],{"class":72}," [[ $cmd ",[66,817,818],{"class":76},"=~",[66,820,821],{"class":72}," ^$patt1$ ",[66,823,824],{"class":76},"||",[66,826,827],{"class":72}," $cmd ",[66,829,818],{"class":76},[66,831,832],{"class":72}," ^$patt2$ ",[66,834,824],{"class":76},[66,836,827],{"class":72},[66,838,818],{"class":76},[66,840,841],{"class":72}," ^$patt3$ ",[66,843,824],{"class":76},[66,845,827],{"class":72},[66,847,818],{"class":76},[66,849,850],{"class":72}," ^$patt4$ ]]; ",[66,852,767],{"class":76},[66,854,856],{"class":68,"line":855},29,[66,857,858],{"class":72},"    $SSH_ORIGINAL_COMMAND\n",[66,860,862],{"class":68,"line":861},30,[66,863,806],{"class":182},[66,865,867],{"class":68,"line":866},31,[66,868,869],{"class":76},"else\n",[66,871,873,876,879,882,885,888,890],{"class":68,"line":872},32,[66,874,875],{"class":84},"    logger",[66,877,878],{"class":80}," \"$(",[66,880,881],{"class":84},"basename",[66,883,884],{"class":182}," $0",[66,886,887],{"class":80},") violation: ",[66,889,753],{"class":72},[66,891,673],{"class":80},[66,893,895,898],{"class":68,"line":894},33,[66,896,897],{"class":182},"    echo",[66,899,900],{"class":80}," \"Access denied\"\n",[66,902,904,907],{"class":68,"line":903},34,[66,905,906],{"class":182},"    exit",[66,908,909],{"class":182}," 1\n",[66,911,913],{"class":68,"line":912},35,[66,914,915],{"class":76},"fi\n",[12,917,918,919,922],{},"We can then test the magic ",[16,920,921],{},"list-datasets"," command to get a server list of all datasets and mountpoints:",[57,924,926],{"className":59,"code":925,"language":61,"meta":62,"style":62},"extbackup$ ssh backup list-datasets\n",[16,927,928],{"__ignoreMap":62},[66,929,930,932,935,938],{"class":68,"line":69},[66,931,308],{"class":84},[66,933,934],{"class":80}," ssh",[66,936,937],{"class":80}," backup",[66,939,940],{"class":80}," list-datasets\n",[12,942,943,944,947],{},"And ",[16,945,946],{},"pve-zsync"," is able to execute remote commands like such:",[57,949,951],{"className":59,"code":950,"language":61,"meta":62,"style":62},"$ zfs list -r -t snapshot -Ho name -S creation dpool\u002Fzfsdisks\u002Fsubvol-181-disk-1\n$ zfs snapshot dpool\u002Fzfsdisks\u002Fsubvol-181-disk-1@rep_extbackup_2021-07-12_23:15:53\n$ zfs send -- dpool\u002Fzfsdisks\u002Fsubvol-181-disk-1@rep_extbackup_2021-07-12_23:15:53\n$ zfs destroy dpool\u002Fzfsdisks\u002Fsubvol-181-disk-1@rep_extbackup_2021-07-12_23:13:13\n",[16,952,953,987,998,1012],{"__ignoreMap":62},[66,954,955,958,961,963,966,969,972,975,978,981,984],{"class":68,"line":69},[66,956,957],{"class":84},"$",[66,959,960],{"class":80}," zfs",[66,962,782],{"class":80},[66,964,965],{"class":182}," -r",[66,967,968],{"class":182}," -t",[66,970,971],{"class":80}," snapshot",[66,973,974],{"class":182}," -Ho",[66,976,977],{"class":80}," name",[66,979,980],{"class":182}," -S",[66,982,983],{"class":80}," creation",[66,985,986],{"class":80}," dpool\u002Fzfsdisks\u002Fsubvol-181-disk-1\n",[66,988,989,991,993,995],{"class":68,"line":174},[66,990,957],{"class":84},[66,992,960],{"class":80},[66,994,971],{"class":80},[66,996,997],{"class":80}," dpool\u002Fzfsdisks\u002Fsubvol-181-disk-1@rep_extbackup_2021-07-12_23:15:53\n",[66,999,1000,1002,1004,1007,1010],{"class":68,"line":188},[66,1001,957],{"class":84},[66,1003,960],{"class":80},[66,1005,1006],{"class":80}," send",[66,1008,1009],{"class":182}," --",[66,1011,997],{"class":80},[66,1013,1014,1016,1018,1021],{"class":68,"line":493},[66,1015,957],{"class":84},[66,1017,960],{"class":80},[66,1019,1020],{"class":80}," destroy",[66,1022,1023],{"class":80}," dpool\u002Fzfsdisks\u002Fsubvol-181-disk-1@rep_extbackup_2021-07-12_23:13:13\n",[12,1025,1026,1027,1030],{},"Whenever we try to fire another command, we get an ",[16,1028,1029],{},"Access denied"," and the command is logged to syslog.",[12,1032,1033,1034,1036],{},"Sidenote: I trust ",[16,1035,145],{}," as a client, especially since its SSH private key is encrypted and is only getting decrypted to volatile memory. But I still wanted to restrict it to a small subset of commands, and also to a subset of ZFS datasets it can pull data from, for improved security.",[12,1038,1039,1040,1042],{},"OpenSSH's ",[16,1041,18],{}," command option gives us full flexibility with such a wrapper script!",[1044,1045,1046],"style",{},"html pre.shiki code .s_bOF, html code.shiki .s_bOF{--shiki-light:#1F2328;--shiki-default:#1F2328;--shiki-dark:#E6EDF3}html pre.shiki code .s5nWI, html code.shiki .s5nWI{--shiki-light:#CF222E;--shiki-default:#CF222E;--shiki-dark:#FF7B72}html pre.shiki code .s-BGO, html code.shiki .s-BGO{--shiki-light:#0A3069;--shiki-default:#0A3069;--shiki-dark:#A5D6FF}html pre.shiki code .sQJ0q, html code.shiki .sQJ0q{--shiki-light:#953800;--shiki-default:#953800;--shiki-dark:#FFA657}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sDkKp, html code.shiki .sDkKp{--shiki-light:#0550AE;--shiki-default:#0550AE;--shiki-dark:#79C0FF}html pre.shiki code .s9BHP, html code.shiki .s9BHP{--shiki-light:#6E7781;--shiki-default:#6E7781;--shiki-dark:#8B949E}",{"title":62,"searchDepth":174,"depth":188,"links":1048},[1049,1050],{"id":130,"depth":174,"text":131},{"id":360,"depth":174,"text":361},null,"2021-08-03 16:00","Limit SSH access to specific commands by the lovely command option in authorized_keys.",{"type":9,"value":1055},[1056,1062],[12,1057,14,1058,19,1060,23],{},[16,1059,18],{},[16,1061,22],{},[12,1063,1064,28],{},[16,1065,18],{},"md","\u002Fimages\u002Fcovers\u002Fssh-key.png",{},"\u002Farticles\u002F20210803-ssh-allowed-commands",false,{"title":6,"description":1053},"articles\u002F20210803-ssh-allowed-commands",[1074,1075,1076],"sysadmin","linux","security","aQnCTJ7B5UELJaycjNAu43tHvEE3I83Zi2BzS4SxvK0",[1079,1082],{"title":401,"path":121,"stem":1080,"createdAt":1081,"children":-1},"articles\u002F20210803-secure-zfs-encrypted-extbackup","2021-08-03 12:00",{"title":1083,"path":1084,"stem":1085,"createdAt":1086,"children":-1},"Configure ESLint and Prettier for Vue\u002FNuxt.js project in VS Code","\u002Farticles\u002F20210805-eslint-prettier-for-vscode","articles\u002F20210805-eslint-prettier-for-vscode","2021-08-05 17:48",1794961391369]